X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2FCSSMin.php;h=1cbcbde1e0fd6856f3081f321c4aab5facd2bc44;hp=f2c7ed29f0530303ebba931a41d2466839d544a1;hb=9b670fb797813a8ed35750e2c83fe953a10f349e;hpb=b3dc5c17af1aee314d568ba20bc1b4122573686f diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index f2c7ed29f0..1cbcbde1e0 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -424,11 +424,11 @@ class CSSMin { // is only supported in PHP 5.6. Use a getter method for now. $urlRegex = '(' . // Unquoted url - 'url\(\s*(?P[^\'"][^\?\)]*?)(?P\?[^\)]*?|)\s*\)' . + 'url\(\s*(?P[^\'"][^\?\)]+?)(?P\?[^\)]*?|)\s*\)' . // Single quoted url - '|url\(\s*\'(?P[^\?\']*?)(?P\?[^\']*?|)\'\s*\)' . + '|url\(\s*\'(?P[^\?\']+?)(?P\?[^\']*?|)\'\s*\)' . // Double quoted url - '|url\(\s*"(?P[^\?"]*?)(?P\?[^"]*?|)"\s*\)' . + '|url\(\s*"(?P[^\?"]+?)(?P\?[^"]*?|)"\s*\)' . ')'; } return $urlRegex; @@ -446,6 +446,9 @@ class CSSMin { $match['file'] = $match['file1']; $match['query'] = $match['query1']; } else { + if ( !isset( $match['file2'] ) || $match['file2'][1] === -1 ) { + throw new Exception( 'URL must be non-empty' ); + } $match['file'] = $match['file2']; $match['query'] = $match['query2']; } @@ -457,6 +460,9 @@ class CSSMin { $match['file'] = $match['file1']; $match['query'] = $match['query1']; } else { + if ( !isset( $match['file2'] ) || $match['file2'] === '' ) { + throw new Exception( 'URL must be non-empty' ); + } $match['file'] = $match['file2']; $match['query'] = $match['query2']; } @@ -535,8 +541,8 @@ class CSSMin { public static function minify( $css ) { return trim( str_replace( - [ '; ', ': ', ' {', '{ ', ', ', '} ', ';}' ], - [ ';', ':', '{', '{', ',', '}', '}' ], + [ '; ', ': ', ' {', '{ ', ', ', '} ', ';}', '( ', ' )', '[ ', ' ]' ], + [ ';', ':', '{', '{', ',', '}', '}', '(', ')', '[', ']' ], preg_replace( [ '/\s+/', '/\/\*.*?\*\//s' ], [ ' ', '' ], $css ) ) );