X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Flibs%2FCSSMin.php;h=c69e79f5b23ee127fa795c333dc01bbe034f4fb2;hb=e6e68618810b828a7de84dfe164e768da8ba90bf;hp=4e2ca836d85e25316bc74f16dbaa5e71cd8e53bf;hpb=914e7e2b5d34104bd9ae800f632c68ddc6eecef1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index 4e2ca836d8..c69e79f5b2 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -135,27 +135,21 @@ class CSSMin { */ public static function getMimeType( $file ) { $realpath = realpath( $file ); - // Try a couple of different ways to get the MIME-type of a file, in order of - // preference if ( $realpath && function_exists( 'finfo_file' ) && function_exists( 'finfo_open' ) && defined( 'FILEINFO_MIME_TYPE' ) ) { - // As of PHP 5.3, this is how you get the MIME-type of a file; it uses the Fileinfo - // PECL extension return finfo_file( finfo_open( FILEINFO_MIME_TYPE ), $realpath ); - } elseif ( function_exists( 'mime_content_type' ) ) { - // Before this was deprecated in PHP 5.3, this was how you got the MIME-type of a file - return mime_content_type( $file ); - } else { - // Worst-case scenario has happened, use the file extension to infer the MIME-type - $ext = strtolower( pathinfo( $file, PATHINFO_EXTENSION ) ); - if ( isset( self::$mimeTypes[$ext] ) ) { - return self::$mimeTypes[$ext]; - } } + + // Infer the MIME-type from the file extension + $ext = strtolower( pathinfo( $file, PATHINFO_EXTENSION ) ); + if ( isset( self::$mimeTypes[$ext] ) ) { + return self::$mimeTypes[$ext]; + } + return false; } @@ -206,10 +200,9 @@ class CSSMin { $remote = substr( $remote, 0, -1 ); } - // Replace all comments by a placeholder so they will not interfere - // with the remapping - // Warning: This will also catch on anything looking like the start of - // a comment between quotation marks (e.g. "foo /* bar"). + // Replace all comments by a placeholder so they will not interfere with the remapping. + // Warning: This will also catch on anything looking like the start of a comment between + // quotation marks (e.g. "foo /* bar"). $comments = array(); $placeholder = uniqid( '', true ); @@ -232,12 +225,13 @@ class CSSMin { $source = preg_replace_callback( $pattern, - function ( $matchOuter ) use ( $local, $remote, $embedData ) { + function ( $matchOuter ) use ( $local, $remote, $embedData, $placeholder ) { $rule = $matchOuter[0]; - // Check for global @embed comment and remove it + // Check for global @embed comment and remove it. Allow other comments to be present + // before @embed (they have been replaced with placeholders at this point). $embedAll = false; - $rule = preg_replace( '/^(\s*)' . CSSMin::EMBED_REGEX . '\s*/', '$1', $rule, 1, $embedAll ); + $rule = preg_replace( '/^((?:\s+|' . $placeholder . '(\d+)x)*)' . CSSMin::EMBED_REGEX . '\s*/', '$1', $rule, 1, $embedAll ); // Build two versions of current rule: with remapped URLs // and with embedded data: URIs (where possible).