php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #54180
Patch bug54180_patch revision 2011-03-07 22:33 UTC by tomas dot brastavicius at quantum dot lt

Patch bug54180_patch for URL related Bug #54180

Patch version 2011-03-07 22:33 UTC

Return to Bug #54180 | Download this patch
Patch Revisions:

Developer: tomas.brastavicius@quantum.lt

Index: ext/standard/url.c
===================================================================
--- ext/standard/url.c	(revision 309010)
+++ ext/standard/url.c	(working copy)
@@ -316,6 +316,10 @@
 		pp = strchr(s, '#');
 
 		if (pp && pp < p) {
+			if (pp - s) {
+				ret->path = estrndup(s, (pp-s));
+				php_replace_controlchars_ex(ret->path, (pp - s));
+			}
 			p = pp;
 			goto label_parse;
 		}
Index: ext/standard/tests/url/bug54180.phpt
===================================================================
--- ext/standard/tests/url/bug54180.phpt	(revision 0)
+++ ext/standard/tests/url/bug54180.phpt	(revision 0)
@@ -0,0 +1,32 @@
+--TEST--
+Bug #54180 (parse_url() incorrectly parses path when ? in fragment)
+--FILE--
+<?php
+
+var_dump(parse_url("http://example.com/path/script.html?t=1#fragment?data"));
+var_dump(parse_url("http://example.com/path/script.html#fragment?data"));
+
+?>
+--EXPECTF--
+array(5) {
+  ["scheme"]=>
+  string(4) "http"
+  ["host"]=>
+  string(11) "example.com"
+  ["path"]=>
+  string(17) "/path/script.html"
+  ["query"]=>
+  string(3) "t=1"
+  ["fragment"]=>
+  string(13) "fragment?data"
+}
+array(4) {
+  ["scheme"]=>
+  string(4) "http"
+  ["host"]=>
+  string(11) "example.com"
+  ["path"]=>
+  string(17) "/path/script.html"
+  ["fragment"]=>
+  string(13) "fragment?data"
+}
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 20:02:09 2014 UTC