Skip to content

Commit cfdac5e

Browse files
committed
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.
1 parent be63a5d commit cfdac5e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/Cake/Test/Case/View/HelperTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,9 @@ public function testAssetUrl() {
660660

661661
$result = $this->Helper->assetUrl('foo.jpg?one=two&three=four');
662662
$this->assertEquals('foo.jpg?one=two&three=four', $result);
663+
664+
$result = $this->Helper->assetUrl('dir/big+tall/image', array('ext' => '.jpg'));
665+
$this->assertEquals('dir/big%2Btall/image.jpg', $result);
663666
}
664667

665668
/**
@@ -674,7 +677,8 @@ public function testAssetUrlNoRewrite() {
674677
'here' => '/cake_dev/index.php/tasks',
675678
));
676679
$result = $this->Helper->assetUrl('img/cake.icon.png', array('fullBase' => true));
677-
$this->assertEquals('http://localhost/cake_dev/app/webroot/img/cake.icon.png', $result);
680+
681+
$this->assertEquals($result, 'http://' . $_SERVER['HTTP_HOST'] . '/cake_dev/app/webroot/img/cake.icon.png');
678682
}
679683

680684
/**

lib/Cake/View/Helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public function assetUrl($path, $options = array()) {
341341
*/
342342
protected function _encodeUrl($url) {
343343
$path = parse_url($url, PHP_URL_PATH);
344-
$parts = array_map('urldecode', explode('/', $path));
344+
$parts = array_map('rawurldecode', explode('/', $path));
345345
$parts = array_map('rawurlencode', $parts);
346346
$encoded = implode('/', $parts);
347347
return h(str_replace($path, $encoded, $url));

0 commit comments

Comments
 (0)