Skip to content

Commit

Permalink
Fixes zendframework#13 : reserved characters in path should be unencoded
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jul 14, 2017
1 parent bd0b25a commit 2cb5e12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
10 changes: 10 additions & 0 deletions test/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1346,4 +1346,14 @@ 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());
}
}

0 comments on commit 2cb5e12

Please sign in to comment.