mirror of
https://github.com/getgrav/grav.git
synced 2026-07-07 16:22:59 +02:00
Fixed issue with Utils::normalizePath messing with external URLs #2216
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
|
||||
1. [](#new)
|
||||
* Added `Blueprint::addDynamicHandler()` method to allow custom dynamic handlers, for example `custom-options@: getCustomOptions`
|
||||
1. [](#bugfix)
|
||||
* Missed a `CacheCommand` reference in `bin/grav` [#2442](https://github.com/getgrav/grav/issues/2442)
|
||||
* Fixed issue with `Utils::normalizePath` messing with external URLs [#2216](https://github.com/getgrav/grav/issues/2216)
|
||||
|
||||
# v1.6.2
|
||||
## 04/11/2019
|
||||
|
||||
@@ -784,6 +784,11 @@ abstract class Utils
|
||||
*/
|
||||
public static function normalizePath($path)
|
||||
{
|
||||
|
||||
if (Uri::isExternal($path)) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
$root = '';
|
||||
preg_match(self::ROOTURL_REGEX, $path, $matches);
|
||||
if ($matches) {
|
||||
|
||||
@@ -225,9 +225,8 @@ class UtilsTest extends \Codeception\TestCase\Test
|
||||
$this->assertEquals('/test', Utils::normalizePath('/../test'));
|
||||
$this->assertEquals('/test2', Utils::normalizePath('/test/../test2'));
|
||||
$this->assertEquals('/test/test2', Utils::normalizePath('/test/./test2'));
|
||||
$this->assertEquals('//something/test/test2', Utils::normalizePath('//../something/test/test2'));
|
||||
$this->assertEquals('//something/test2', Utils::normalizePath('//something/test/../test2'));
|
||||
$this->assertEquals('//test2', Utils::normalizePath('//something/../test/../test2'));
|
||||
$this->assertEquals('https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css', Utils::normalizePath('https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css'));
|
||||
$this->assertEquals('//something.com/../test/test2', Utils::normalizePath('//something.com/../test/test2'));
|
||||
}
|
||||
|
||||
public function testIsFunctionDisabled()
|
||||
|
||||
Reference in New Issue
Block a user