Skip to content

Commit

Permalink
Allow plus signs in URL's to pass unscathed in Helper functions.
Browse files Browse the repository at this point in the history
According to  RFC 1738 the plus sign does not have special meaning outisde of the query part of a URL.
  • Loading branch information
HaroldPutman committed Jun 21, 2013
1 parent be63a5d commit cfdac5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/Cake/Test/Case/View/HelperTest.php
Expand Up @@ -660,6 +660,9 @@ public function testAssetUrl() {

$result = $this->Helper->assetUrl('foo.jpg?one=two&three=four');
$this->assertEquals('foo.jpg?one=two&three=four', $result);

$result = $this->Helper->assetUrl('dir/big+tall/image', array('ext' => '.jpg'));
$this->assertEquals('dir/big%2Btall/image.jpg', $result);
}

/**
Expand All @@ -674,7 +677,8 @@ public function testAssetUrlNoRewrite() {
'here' => '/cake_dev/index.php/tasks',
));
$result = $this->Helper->assetUrl('img/cake.icon.png', array('fullBase' => true));
$this->assertEquals('http://localhost/cake_dev/app/webroot/img/cake.icon.png', $result);

$this->assertEquals($result, 'http://' . $_SERVER['HTTP_HOST'] . '/cake_dev/app/webroot/img/cake.icon.png');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper.php
Expand Up @@ -341,7 +341,7 @@ public function assetUrl($path, $options = array()) {
*/
protected function _encodeUrl($url) {
$path = parse_url($url, PHP_URL_PATH);
$parts = array_map('urldecode', explode('/', $path));
$parts = array_map('rawurldecode', explode('/', $path));
$parts = array_map('rawurlencode', $parts);
$encoded = implode('/', $parts);
return h(str_replace($path, $encoded, $url));
Expand Down

0 comments on commit cfdac5e

Please sign in to comment.