iliaa                                    Wed, 04 Nov 2009 13:44:10 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=290199

Log:
Fixed bug #50073 (parse_url() incorrect when ? in fragment).

Bug: http://bugs.php.net/50073 (Assigned) parse_url incorrect when ? in fragment
      
Changed paths:
    U   php/php-src/branches/PHP_5_2/NEWS
    U   php/php-src/branches/PHP_5_2/ext/standard/url.c
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/standard/url.c
    U   php/php-src/trunk/ext/standard/url.c

Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS   2009-11-04 12:59:55 UTC (rev 290198)
+++ php/php-src/branches/PHP_5_2/NEWS   2009-11-04 13:44:10 UTC (rev 290199)
@@ -19,6 +19,7 @@
   (Felipe)
 - Fixed memory leak in openssl_pkcs12_export_to_file(). (Felipe)

+- Fixed bug #50073 (parse_url() incorrect when ? in fragment). (Ilia)
 - Fixed bug #50006 (Segfault caused by uksort()). (Felipe)
 - Fixed bug #49990 (SNMP3 warning message about security level printed twice).
   (Jani)

Modified: php/php-src/branches/PHP_5_2/ext/standard/url.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/url.c     2009-11-04 12:59:55 UTC 
(rev 290198)
+++ php/php-src/branches/PHP_5_2/ext/standard/url.c     2009-11-04 13:44:10 UTC 
(rev 290199)
@@ -201,10 +201,21 @@
        e = ue;

        if (!(p = memchr(s, '/', (ue - s)))) {
-               if ((p = memchr(s, '?', (ue - s)))) {
-                       e = p;
-               } else if ((p = memchr(s, '#', (ue - s)))) {
-                       e = p;
+               char *query, *fragment;
+
+               query = memchr(s, '?', (ue - s));
+               fragment = memchr(s, '#', (ue - s));
+
+               if (query && fragment) {
+                       if (query > fragment) {
+                               p = e = fragment;
+                       } else {
+                               p = e = query;
+                       }
+               } else if (query) {
+                       p = e = query;
+               } else if (fragment) {
+                       p = e = fragment;
                }
        } else {
                e = p;
@@ -285,10 +296,10 @@

        if ((p = memchr(s, '?', (ue - s)))) {
                pp = strchr(s, '#');
-
+
                if (pp && pp < p) {
                        p = pp;
-                       pp = strchr(pp+2, '#');
+                       goto label_parse;
                }

                if (p - s) {

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2009-11-04 12:59:55 UTC (rev 290198)
+++ php/php-src/branches/PHP_5_3/NEWS   2009-11-04 13:44:10 UTC (rev 290199)
@@ -17,6 +17,7 @@
 - Fixed memory leak in extension loading when an error occurs on Windows.
   (Pierre)

+- Fixed bug #50073 (parse_url() incorrect when ? in fragment). (Ilia)
 - Fixed bug #50023 (pdo_mysql doesn't use PHP_MYSQL_UNIX_SOCK_ADDR). (Ilia)
 - Fixed bug #49908 (throwing exception in __autoload crashes when interface
   is not defined). (Felipe)

Modified: php/php-src/branches/PHP_5_3/ext/standard/url.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/url.c     2009-11-04 12:59:55 UTC 
(rev 290198)
+++ php/php-src/branches/PHP_5_3/ext/standard/url.c     2009-11-04 13:44:10 UTC 
(rev 290199)
@@ -201,10 +201,21 @@
        e = ue;

        if (!(p = memchr(s, '/', (ue - s)))) {
-               if ((p = memchr(s, '?', (ue - s)))) {
-                       e = p;
-               } else if ((p = memchr(s, '#', (ue - s)))) {
-                       e = p;
+               char *query, *fragment;
+
+               query = memchr(s, '?', (ue - s));
+               fragment = memchr(s, '#', (ue - s));
+
+               if (query && fragment) {
+                       if (query > fragment) {
+                               p = e = fragment;
+                       } else {
+                               p = e = query;
+                       }
+               } else if (query) {
+                       p = e = query;
+               } else if (fragment) {
+                       p = e = fragment;
                }
        } else {
                e = p;
@@ -285,10 +296,10 @@

        if ((p = memchr(s, '?', (ue - s)))) {
                pp = strchr(s, '#');
-
+
                if (pp && pp < p) {
                        p = pp;
-                       pp = strchr(pp+2, '#');
+                       goto label_parse;
                }

                if (p - s) {

Modified: php/php-src/trunk/ext/standard/url.c
===================================================================
--- php/php-src/trunk/ext/standard/url.c        2009-11-04 12:59:55 UTC (rev 
290198)
+++ php/php-src/trunk/ext/standard/url.c        2009-11-04 13:44:10 UTC (rev 
290199)
@@ -257,10 +257,21 @@
        e = ue;

        if (!(p = memchr(s, '/', (ue - s)))) {
-               if ((p = memchr(s, '?', (ue - s)))) {
-                       e = p;
-               } else if ((p = memchr(s, '#', (ue - s)))) {
-                       e = p;
+               char *query, *fragment;
+
+               query = memchr(s, '?', (ue - s));
+               fragment = memchr(s, '#', (ue - s));
+
+               if (query && fragment) {
+                       if (query > fragment) {
+                               p = e = fragment;
+                       } else {
+                               p = e = query;
+                       }
+               } else if (query) {
+                       p = e = query;
+               } else if (fragment) {
+                       p = e = fragment;
                }
        } else {
                e = p;
@@ -341,10 +352,10 @@

        if ((p = memchr(s, '?', (ue - s)))) {
                pp = strchr(s, '#');
-
+
                if (pp && pp < p) {
                        p = pp;
-                       pp = strchr(pp+2, '#');
+                       goto label_parse;
                }

                if (p - s) {

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

Reply via email to