[php-src] master: Merge branch 'PHP-8.6'
| From: | Máté Kocsis | Date: | Sun, 27 Sep 2026 19:12:54 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141607@lists.php.net to get a copy of this message | ||
Author: Máté Kocsis (kocsismate)
Date: 2026-09-27T21:12:27+02:00
Commit: https://github.com/php/php-src/commit/62e2f866c6c2c032e58c8a757a11de5e7671189d
Raw diff: https://github.com/php/php-src/commit/62e2f866c6c2c032e58c8a757a11de5e7671189d.diff
Merge branch 'PHP-8.6'
* PHP-8.6:
ext/uri: fixed url path resolution (#23817)
Changed paths:
A ext/uri/tests/whatwg/builder/path_success_hashmark_with_base.phpt
M ext/uri/uri_parser_whatwg.c
Diff:
diff --git a/ext/uri/tests/whatwg/builder/path_success_hashmark_with_base.phpt
b/ext/uri/tests/whatwg/builder/path_success_hashmark_with_base.phpt
new file mode 100644
index 000000000000..0f385b2d73f7
--- /dev/null
+++ b/ext/uri/tests/whatwg/builder/path_success_hashmark_with_base.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Test Uri\WhatWg\UrlBuilder::setPath() - success - hashmark with base URL
+--FILE--
+<?php
+
+$base = new Uri\WhatWg\Url('https://user:pass@example.com:123/base/path?oldQuery#oldFragment');
+
+$errors = [];
+
+$url = new Uri\WhatWg\UrlBuilder()
+ ->setPath('newPath#value')
+ ->build($base, $errors);
+
+var_dump($url->toAsciiString());
+var_dump($url);
+var_dump($errors);
+var_dump($url->equals(new Uri\WhatWg\Url($url->toAsciiString())));
+var_dump($url->equals(new Uri\WhatWg\Url('newPath%23value', $base),
Uri\UriComparisonMode::IncludeFragment));
+
+?>
+--EXPECTF--
+string(54) "https://user:pass@example.com:123/base/newPath%23value"
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ string(4) "user"
+ ["password"]=>
+ string(4) "pass"
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ int(123)
+ ["path"]=>
+ string(21) "/base/newPath%23value"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ object(Uri\WhatWg\UrlValidationError)#%d (%d) {
+ ["context"]=>
+ string(6) "#value"
+ ["type"]=>
+ enum(Uri\WhatWg\UrlValidationErrorType::InvalidUrlUnit)
+ ["failure"]=>
+ bool(false)
+ }
+}
+bool(true)
+bool(true)
diff --git a/ext/uri/uri_parser_whatwg.c b/ext/uri/uri_parser_whatwg.c
index 3e1e587da75c..5170849e3285 100644
--- a/ext/uri/uri_parser_whatwg.c
+++ b/ext/uri/uri_parser_whatwg.c
@@ -1137,6 +1137,10 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2, 3, 4, 5, 6, 7, 8, 9) lxb_url_t
*php_uri_parser
smart_str_appends(&reference, "%3F");
} else if (*p == '#') {
smart_str_appends(&reference, "%23");
+ const char *reason;
+ append_validation_error(
+ Z_ARRVAL(errors), LXB_URL_ERROR_TYPE_INVALID_URL_UNIT, p, &reason
+ );
} else {
smart_str_appendc(&reference, *p);
}