Allow plus signs in URL's to pass unscathed in Helper functions.

According to  RFC 1738 the plus sign does not have special meaning outisde of the query part of a URL.
This commit is contained in:
Harold Putman 2013-06-21 14:24:39 -04:00
parent be63a5d59f
commit cfdac5e32d
2 changed files with 6 additions and 2 deletions

View file

@ -660,6 +660,9 @@ class HelperTest extends CakeTestCase {
$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);
}
/**
@ -674,7 +677,8 @@ class HelperTest extends CakeTestCase {
'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');
}
/**

View file

@ -341,7 +341,7 @@ class Helper extends Object {
*/
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));