felipe          Thu, 16 Jul 2009 23:28:12 +0000

URL: http://svn.php.net/viewvc?view=revision&revision=284211

Changed paths:
        U   php/php-src/trunk/ext/filter/logical_filters.c
        A   php/php-src/trunk/ext/filter/tests/bug48762.phpt

Log:
- Fixed bug #48762 (IPv6 address filter still rejects valid address)

Modified: php/php-src/trunk/ext/filter/logical_filters.c
===================================================================
--- php/php-src/trunk/ext/filter/logical_filters.c      2009-07-16 22:51:38 UTC 
(rev 284210)
+++ php/php-src/trunk/ext/filter/logical_filters.c      2009-07-16 23:28:12 UTC 
(rev 284211)
@@ -533,7 +533,7 @@
        int compressed = 0;
        int blocks = 8;
        int n;
-       char *ipv4 = NULL;
+       char *ipv4;
        char *end;
        int ip4elm[4];
        char *s = str;
@@ -559,24 +559,21 @@
                blocks = 6;
        }

-       end = ipv4 ? ipv4 : str + str_len;
+       end = str + str_len;

        while (str < end) {
                if (*str == ':') {
                        if (--blocks == 0) {
-                               if ((str+1) == end && ipv4) {
-                                       return 1;
-                               }
                                return 0;
                        }
                        if (++str >= end) {
-                               return (ipv4 && ipv4 == str && blocks == 3) || 
0;
+                               return 0;
                        }
                        if (*str == ':') {
                                if (compressed || --blocks == 0) {
                                        return 0;
                                }
-                               if (++str == end || (ipv4 && ipv4 == str)) {
+                               if (++str == end) {
                                        return 1;
                                }
                                compressed = 1;

Added: php/php-src/trunk/ext/filter/tests/bug48762.phpt
===================================================================
--- php/php-src/trunk/ext/filter/tests/bug48762.phpt                            
(rev 0)
+++ php/php-src/trunk/ext/filter/tests/bug48762.phpt    2009-07-16 23:28:12 UTC 
(rev 284211)
@@ -0,0 +1,12 @@
+--TEST--
+Bug #48762 (IPv6 address filter still rejects valid address)
+--FILE--
+<?php
+
+var_dump(filter_var('0b15:23::3:67.98.234.17', FILTER_VALIDATE_IP, 
FILTER_FLAG_IPV6));
+var_dump(filter_var('::67:78b:34.43.43.2', FILTER_VALIDATE_IP, 
FILTER_FLAG_IPV6));
+
+?>
+--EXPECT--
+string(23) "0b15:23::3:67.98.234.17"
+string(19) "::67:78b:34.43.43.2"


Property changes on: php/php-src/trunk/ext/filter/tests/bug48762.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to