diff --git a/CHANGELOG.md b/CHANGELOG.md index ecc74d610..ed77a356b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,9 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- Nothing. +- [#17](https://github.com/zendframework/zend-uri/pull/17) updates the path + encoding algorithm to allow `(` and `)` characters as path characters (per + the RFC-3986, these are valid sub-delimiters allowed within a path). ## 2.5.2 - 2016-02-17 diff --git a/src/Uri.php b/src/Uri.php index f58345368..182067e35 100644 --- a/src/Uri.php +++ b/src/Uri.php @@ -1007,7 +1007,7 @@ public static function encodePath($path) )); } - $regex = '/(?:[^' . self::CHAR_UNRESERVED . ':@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/'; + $regex = '/(?:[^' . self::CHAR_UNRESERVED . ')(:@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/'; $escaper = static::getEscaper(); $replace = function ($match) use ($escaper) { return $escaper->escapeUrl($match[0]); diff --git a/test/UriTest.php b/test/UriTest.php index f7409f535..4d467d9c0 100644 --- a/test/UriTest.php +++ b/test/UriTest.php @@ -1360,4 +1360,17 @@ public function testParseTwice() $this->assertNull($uri->getQuery()); $this->assertNull($uri->getFragment()); } + + public function testReservedCharsInPathUnencoded() + { + $uri = new Uri(); + $uri->setScheme('https'); + $uri->setHost('api.linkedin.com'); + $uri->setPath('/v1/people/~:(first-name,last-name,email-address,picture-url)'); + + $this->assertSame( + 'https://api.linkedin.com/v1/people/~:(first-name,last-name,email-address,picture-url)', + $uri->toString() + ); + } }