From 0a2c361a43b2e5c84baa91656ce5b336a763c09c Mon Sep 17 00:00:00 2001 From: upstream Date: Sun, 6 Sep 2026 06:07:07 +0200 Subject: [PATCH] Upstream thephpleague/uri-src state of the touched files before 3ad4f269f2 --- uri/UriTemplate/Operator.php | 6 ++---- uri/UriTemplateTest.php | 14 -------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/uri/UriTemplate/Operator.php b/uri/UriTemplate/Operator.php index 1738a38..0316b80 100644 --- a/uri/UriTemplate/Operator.php +++ b/uri/UriTemplate/Operator.php @@ -19,10 +19,10 @@ use Stringable; use function implode; use function is_array; -use function mb_substr; use function preg_match; use function rawurlencode; use function str_contains; +use function substr; /** * Processing behavior according to the expression type operator. @@ -156,9 +156,7 @@ enum Operator: string } if (':' === $varSpec->modifier) { - // RFC 6570 Section 2.4.1: the prefix length is a count of characters, not octets, - // so a multibyte-aware truncation is required to avoid splitting a UTF-8 character. - $value = mb_substr($value, 0, $varSpec->position, 'UTF-8'); + $value = substr($value, 0, $varSpec->position); } return [$this->decode($value), $this->isNamed()]; diff --git a/uri/UriTemplateTest.php b/uri/UriTemplateTest.php index 61eab86..281f2fc 100644 --- a/uri/UriTemplateTest.php +++ b/uri/UriTemplateTest.php @@ -261,20 +261,6 @@ final class UriTemplateTest extends TestCase self::assertSame($expectedUri, $uriTemplate->expandToUrlOrFail($variables)->toAsciiString()); } - public function testPrefixModifierTruncatesByCharacterNotByte(): void - { - // RFC 6570 Section 2.4.1: the prefix length counts characters, not octets, so a - // multibyte character must never be split. The euro sign and the musical G-clef - // are 3 and 4 bytes in UTF-8, respectively, but each is a single character. - $uriTemplate = new UriTemplate('{?currency:1}{clef:1}'); - $variables = [ - 'currency' => "\u{20AC}uro", - 'clef' => "\u{1D11E}stave", - ]; - - self::assertSame('?currency=%E2%82%AC%F0%9D%84%9E', $uriTemplate->expand($variables)->toString()); - } - public function testDisallowNestedArrayExpansion(): void { $template = 'http://example.com{?query,data*,foo*}';