X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2FCSSMin.php;h=cd80066558ed09b3efdf2f70716895515fe92788;hp=ea0f1b7c740d36a5b76ac719568c05da142cbc3d;hb=956c2430c7b8fceb289aaeacc8d6c2e0def2c56e;hpb=be42e09aa866d7def54ead06c91d5dc9c8210ce5 diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index ea0f1b7c74..cd80066558 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -78,7 +78,12 @@ class CSSMin { $url = $match['file'][0]; // Skip fully-qualified and protocol-relative URLs and data URIs - if ( substr( $url, 0, 2 ) === '//' || parse_url( $url, PHP_URL_SCHEME ) ) { + // Also skips the rare `behavior` property specifying application's default behavior + if ( + substr( $url, 0, 2 ) === '//' || + parse_url( $url, PHP_URL_SCHEME ) || + substr( $url, 0, 9 ) === '#default#' + ) { break; } @@ -183,17 +188,7 @@ class CSSMin { return self::$mimeTypes[$ext]; } - $realpath = realpath( $file ); - if ( - $realpath - && function_exists( 'finfo_file' ) - && function_exists( 'finfo_open' ) - && defined( 'FILEINFO_MIME_TYPE' ) - ) { - return finfo_file( finfo_open( FILEINFO_MIME_TYPE ), $realpath ); - } - - return false; + return mime_content_type( realpath( $file ) ); } /** @@ -252,7 +247,7 @@ class CSSMin { // quotation marks (e.g. "foo /* bar"). $comments = []; - $pattern = '/(?!' . CSSMin::EMBED_REGEX . ')(' . CSSMin::COMMENT_REGEX . ')/s'; + $pattern = '/(?!' . self::EMBED_REGEX . ')(' . self::COMMENT_REGEX . ')/s'; $source = preg_replace_callback( $pattern, @@ -355,7 +350,7 @@ class CSSMin { }, $source ); // Re-insert comments - $pattern = '/' . CSSMin::PLACEHOLDER . '(\d+)x/'; + $pattern = '/' . self::PLACEHOLDER . '(\d+)x/'; $source = preg_replace_callback( $pattern, function ( $match ) use ( &$comments ) { return $comments[ $match[1] ]; }, $source ); @@ -389,6 +384,9 @@ class CSSMin { return false; } + /** + * @codeCoverageIgnore + */ private static function getUrlRegex() { static $urlRegex; if ( $urlRegex === null ) { @@ -474,7 +472,12 @@ class CSSMin { // Pass thru fully-qualified and protocol-relative URLs and data URIs, as well as local URLs if // we can't expand them. - if ( self::isRemoteUrl( $url ) || self::isLocalUrl( $url ) ) { + // Also skips the rare `behavior` property specifying application's default behavior + if ( + self::isRemoteUrl( $url ) || + self::isLocalUrl( $url ) || + substr( $url, 0, 9 ) === '#default#' + ) { return $url; }