Skip to content

Commit 90a83e2

Browse files
committed
an empty string for fragment when there are no any chars after #
1 parent 286c6e7 commit 90a83e2

File tree

6 files changed

+19
-28
lines changed

6 files changed

+19
-28
lines changed

ext/standard/tests/strings/url_t.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ $sample_urls = array (
393393
string(3) "foo"
394394
}
395395

396-
--> http://www.php.net:80/?#: array(5) {
396+
--> http://www.php.net:80/?#: array(6) {
397397
["scheme"]=>
398398
string(4) "http"
399399
["host"]=>
@@ -404,6 +404,8 @@ $sample_urls = array (
404404
string(1) "/"
405405
["query"]=>
406406
string(0) ""
407+
["fragment"]=>
408+
string(0) ""
407409
}
408410

409411
--> http://www.php.net:80/?test=1: array(5) {

ext/standard/tests/url/bug78385.phpt

Lines changed: 0 additions & 21 deletions
This file was deleted.

ext/standard/tests/url/parse_url_basic_001.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ echo "Done";
324324
string(3) "foo"
325325
}
326326

327-
--> http://www.php.net:80/?#: array(5) {
327+
--> http://www.php.net:80/?#: array(6) {
328328
["scheme"]=>
329329
string(4) "http"
330330
["host"]=>
@@ -335,6 +335,8 @@ echo "Done";
335335
string(1) "/"
336336
["query"]=>
337337
string(0) ""
338+
["fragment"]=>
339+
string(0) ""
338340
}
339341

340342
--> http://www.php.net:80/?test=1: array(5) {
@@ -777,11 +779,13 @@ echo "Done";
777779
string(0) ""
778780
}
779781

780-
--> http://::#: array(2) {
782+
--> http://::#: array(3) {
781783
["scheme"]=>
782784
string(4) "http"
783785
["host"]=>
784786
string(1) ":"
787+
["fragment"]=>
788+
string(0) ""
785789
}
786790

787791
--> x://::6.5: array(3) {

ext/standard/tests/url/parse_url_basic_009.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ echo "Done";
5454
--> http://www.php.net:80/index.php : NULL
5555
--> http://www.php.net:80/index.php? : NULL
5656
--> http://www.php.net:80/#foo : string(3) "foo"
57-
--> http://www.php.net:80/?# : NULL
57+
--> http://www.php.net:80/?# : string(0) ""
5858
--> http://www.php.net:80/?test=1 : NULL
5959
--> http://www.php.net/?test=1& : NULL
6060
--> http://www.php.net:80/?& : NULL
@@ -96,7 +96,7 @@ echo "Done";
9696
--> x:/blah.com : NULL
9797
--> x://::abc/? : bool(false)
9898
--> http://::? : NULL
99-
--> http://::# : NULL
99+
--> http://::# : string(0) ""
100100
--> x://::6.5 : NULL
101101
--> http://?:/ : bool(false)
102102
--> http://@?:/ : bool(false)

ext/standard/tests/url/parse_url_unterminated.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ echo "Done";
326326
string(3) "foo"
327327
}
328328

329-
--> http://www.php.net:80/?#: array(5) {
329+
--> http://www.php.net:80/?#: array(6) {
330330
["scheme"]=>
331331
string(4) "http"
332332
["host"]=>
@@ -337,6 +337,8 @@ echo "Done";
337337
string(1) "/"
338338
["query"]=>
339339
string(0) ""
340+
["fragment"]=>
341+
string(0) ""
340342
}
341343

342344
--> http://www.php.net:80/?test=1: array(5) {
@@ -779,11 +781,13 @@ echo "Done";
779781
string(0) ""
780782
}
781783

782-
--> http://::#: array(2) {
784+
--> http://::#: array(3) {
783785
["scheme"]=>
784786
string(4) "http"
785787
["host"]=>
786788
string(1) ":"
789+
["fragment"]=>
790+
string(0) ""
787791
}
788792

789793
--> x://::6.5: array(3) {

ext/standard/url.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ PHPAPI php_url *php_url_parse_ex(char const *str, size_t length)
291291
if (p < e) {
292292
ret->fragment = zend_string_init(p, (e - p), 0);
293293
php_replace_controlchars_ex(ZSTR_VAL(ret->fragment), ZSTR_LEN(ret->fragment));
294+
} else {
295+
ret->fragment = ZSTR_EMPTY_ALLOC();
294296
}
295297
e = p-1;
296298
}

0 commit comments

Comments
 (0)