diff --git a/lib/minify/matthiasmullie-pathconverter/LICENSE b/lib/minify/matthiasmullie-pathconverter/LICENSE new file mode 100644 index 00000000000..491295ad30e --- /dev/null +++ b/lib/minify/matthiasmullie-pathconverter/LICENSE @@ -0,0 +1,18 @@ +Copyright (c) 2015 Matthias Mullie + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/lib/minify/matthiasmullie-pathconverter/src/Converter.php b/lib/minify/matthiasmullie-pathconverter/src/Converter.php index c8b0c696a99..519d3c84ff5 100644 --- a/lib/minify/matthiasmullie-pathconverter/src/Converter.php +++ b/lib/minify/matthiasmullie-pathconverter/src/Converter.php @@ -31,21 +31,22 @@ class Converter implements ConverterInterface /** * @param string $from The original base path (directory, not file!) * @param string $to The new base path (directory, not file!) + * @param string $root Root directory (defaults to `getcwd`) */ - public function __construct($from, $to) + public function __construct($from, $to, $root = '') { $shared = $this->shared($from, $to); if ($shared === '') { // when both paths have nothing in common, one of them is probably // absolute while the other is relative - $cwd = getcwd(); - $from = strpos($from, $cwd) === 0 ? $from : $cwd.'/'.$from; - $to = strpos($to, $cwd) === 0 ? $to : $cwd.'/'.$to; + $root = $root ?: getcwd(); + $from = strpos($from, $root) === 0 ? $from : preg_replace('/\/+/', '/', $root.'/'.$from); + $to = strpos($to, $root) === 0 ? $to : preg_replace('/\/+/', '/', $root.'/'.$to); // or traveling the tree via `..` // attempt to resolve path, or assume it's fine if it doesn't exist - $from = realpath($from) ?: $from; - $to = realpath($to) ?: $to; + $from = @realpath($from) ?: $from; + $to = @realpath($to) ?: $to; } $from = $this->dirname($from); @@ -155,7 +156,7 @@ class Converter implements ConverterInterface $to = mb_substr($this->to, mb_strlen($shared)); // add .. for every directory that needs to be traversed to new path - $to = str_repeat('../', mb_substr_count($to, '/')); + $to = str_repeat('../', count(array_filter(explode('/', $to)))); return $to.ltrim($path, '/'); } @@ -169,11 +170,11 @@ class Converter implements ConverterInterface */ protected function dirname($path) { - if (is_file($path)) { + if (@is_file($path)) { return dirname($path); } - if (is_dir($path)) { + if (@is_dir($path)) { return rtrim($path, '/'); } diff --git a/lib/thirdpartylibs.xml b/lib/thirdpartylibs.xml index a7d4d9c3e4e..a7c79f64f23 100644 --- a/lib/thirdpartylibs.xml +++ b/lib/thirdpartylibs.xml @@ -60,7 +60,7 @@ minify/matthiasmullie-pathconverter MatthiasMullie\PathConverter MIT - 1.1.0 + 1.1.2