Fixed issue with Utils::normalizePath messing with external URLs #2216

This commit is contained in:
Andy Miller
2019-04-12 07:55:51 -06:00
parent 0f0e6ab1c8
commit ef7b33f9b6
3 changed files with 10 additions and 3 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -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()