Added system config option legacy_url_root_behavior

This commit is contained in:
Andy Miller 2022-03-03 13:16:48 -07:00
parent b80fcca0cf
commit 4f92568171
No known key found for this signature in database
GPG Key ID: 9F2CF38AEBDB0AE0
3 changed files with 9 additions and 6 deletions

View File

@ -5,6 +5,7 @@
* Added support to get image size for SVG vector images [#3533](https://github.com/getgrav/grav/pull/3533)
* Added XSS check for uploaded SVG files before they get stored
* Fixed phpstan issues (All level 2, Framework level 5)
* Added a `system.legacy_url_root_behavior` config option to enable legacy/broken `Utils::url()` behavior
2. [](#bugfix)
* Fixed `'mbstring' extension is not loaded` error, use Polyfill instead [#3504](https://github.com/getgrav/grav/pull/3504)
* Fixed new `Utils::pathinfo()` and `Utils::basename()` being too strict for legacy use [#3542](https://github.com/getgrav/grav/issues/3542)

View File

@ -15,6 +15,7 @@ http_x_forwarded: # Configuration options for the
host: false
port: true
ip: true
legacy_url_root_behavior: false # Enable legacy root URL behavior that breaks URls with paths that match root
languages:
supported: [] # List of languages supported. eg: [en, fr, de]

View File

@ -134,14 +134,15 @@ abstract class Utils
$resource = $locator->findResource($input, false);
}
} else {
// $root = $uri->rootUrl();
// $pattern = '/(' . '\\' . $root . '[\s\/])/';
// if (preg_match($pattern, $input, $matches)) {
// $input = static::replaceFirstOccurrence($matches[0], '', $input);
// }
// You can manually restore the old legacy behavior that does not produce expected results
if ($grav['config']->get('system.legacy_url_root_behavior', false)) {
$root = $uri->rootUrl();
if (static::startsWith($input, $root)) {
$input = static::replaceFirstOccurrence($root, '', $input);
}
}
$input = ltrim($input, '/');
$resource = $input;
}