Add missing urlencoding to base/webroot.

This fixes URL generation when PHP_SELF or the request path contains
special characters.
This commit is contained in:
mark_story 2013-05-10 11:04:46 -04:00
parent f745a02210
commit 6017db9dc8
4 changed files with 22 additions and 6 deletions

View file

@ -341,10 +341,9 @@ class Helper extends Object {
*/
protected function _encodeUrl($url) {
$path = parse_url($url, PHP_URL_PATH);
$encoded = implode('/', array_map(
'rawurlencode',
explode('/', $path)
));
$parts = array_map('urldecode', explode('/', $path));
$parts = array_map('rawurlencode', $parts);
$encoded = implode('/', $parts);
return h(str_replace($path, $encoded, $url));
}
@ -360,7 +359,11 @@ class Helper extends Object {
$stamp = Configure::read('Asset.timestamp');
$timestampEnabled = $stamp === 'force' || ($stamp === true && Configure::read('debug') > 0);
if ($timestampEnabled && strpos($path, '?') === false) {
$filepath = preg_replace('/^' . preg_quote($this->request->webroot, '/') . '/', '', $path);
$filepath = preg_replace(
'/^' . preg_quote($this->request->webroot, '/') . '/',
'',
urldecode($path)
);
$webrootPath = WWW_ROOT . str_replace('/', DS, $filepath);
if (file_exists($webrootPath)) {
//@codingStandardsIgnoreStart