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

Commit 969ff42

Browse files
committed
Merge branch 'hotfix/211'
Close #211
2 parents 6246866 + 0beec29 commit 969ff42

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ All notable changes to this project will be documented in this file, in reverse
1414
- 499 ('Client Closed Request')
1515
- 510 ('Not Extended')
1616
- 599 ('Network Connect Timeout Error')
17+
- [#211](https://github.com/zendframework/zend-diactoros/pull/211) adds support
18+
for UTF-8 characters in query strings handled by `Zend\Diactoros\Uri`.
1719

1820
### Deprecated
1921

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)