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'
Browse files Browse the repository at this point in the history
Close #211
  • Loading branch information
weierophinney committed Oct 11, 2016
2 parents 6246866 + 0beec29 commit 969ff42
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 969ff42

Please sign in to comment.