mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-07 03:52:41 +00:00
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:
parent
f745a02210
commit
6017db9dc8
4 changed files with 22 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue