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

Commit

Permalink
Merge branch 'hotfix/211' into develop
Browse files Browse the repository at this point in the history
Forward port #211
  • Loading branch information
weierophinney committed Oct 11, 2016
2 parents 32b5775 + 0beec29 commit 3dfe05e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -32,6 +32,8 @@ All notable changes to this project will be documented in this file, in reverse
- 499 ('Client Closed Request')
- 510 ('Not Extended')
- 599 ('Network Connect Timeout Error')
- [#211](https://github.com/zendframework/zend-diactoros/pull/211) adds support
for UTF-8 characters in query strings handled by `Zend\Diactoros\Uri`.

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion src/Uri.php
Expand Up @@ -645,7 +645,7 @@ private function filterFragment($fragment)
private function filterQueryOrFragment($value)
{
return preg_replace_callback(
'/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
'/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/u',
[$this, 'urlEncodeChar'],
$value
);
Expand Down
18 changes: 18 additions & 0 deletions test/UriTest.php
Expand Up @@ -588,6 +588,24 @@ public function utf8PathsDataProvider()
];
}

/**
* @dataProvider utf8QueryStringsDataProvider
*/
public function testUtf8Query($url, $result)
{
$uri = new Uri($url);

$this->assertEquals($result, $uri->getQuery());
}

public function utf8QueryStringsDataProvider()
{
return [
['http://example.com/?q=тестовый_путь', 'q=тестовый_путь'],
['http://example.com/?q=ουτοπία', 'q=ουτοπία'],
];
}

public function testUriDoesNotAppendColonToHostIfPortIsEmpty()
{
$uri = (new Uri())->withHost('google.com');
Expand Down

0 comments on commit 3dfe05e

Please sign in to comment.