Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 7d22370

Browse files
committed
Merge pull request #211 from danizord/hotfix/utf-8-query
Add support for UTF-8 query string
2 parents 6246866 + 20bfa8f commit 7d22370

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Uri.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ private function filterFragment($fragment)
645645
private function filterQueryOrFragment($value)
646646
{
647647
return preg_replace_callback(
648-
'/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
648+
'/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/u',
649649
[$this, 'urlEncodeChar'],
650650
$value
651651
);

test/UriTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,24 @@ public function utf8PathsDataProvider()
588588
];
589589
}
590590

591+
/**
592+
* @dataProvider utf8QueryStringsDataProvider
593+
*/
594+
public function testUtf8Query($url, $result)
595+
{
596+
$uri = new Uri($url);
597+
598+
$this->assertEquals($result, $uri->getQuery());
599+
}
600+
601+
public function utf8QueryStringsDataProvider()
602+
{
603+
return [
604+
['http://example.com/?q=тестовый_путь', 'q=тестовый_путь'],
605+
['http://example.com/?q=ουτοπία', 'q=ουτοπία'],
606+
];
607+
}
608+
591609
public function testUriDoesNotAppendColonToHostIfPortIsEmpty()
592610
{
593611
$uri = (new Uri())->withHost('google.com');

0 commit comments

Comments
 (0)