dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Display PHP version in old version error messages"
[lhc/web/wiklou.git]
/
includes
/
libs
/
CSSMin.php
diff --git
a/includes/libs/CSSMin.php
b/includes/libs/CSSMin.php
index
f2c7ed2
..
73825e8
100644
(file)
--- a/
includes/libs/CSSMin.php
+++ b/
includes/libs/CSSMin.php
@@
-173,18
+173,14
@@
class CSSMin {
/**
* Serialize a string (escape and quote) for use as a CSS string value.
/**
* Serialize a string (escape and quote) for use as a CSS string value.
- * http
://www.w3.org/TR/2013/WD-cssom-20131205
/#serialize-a-string
+ * http
s://www.w3.org/TR/2016/WD-cssom-1-20160317
/#serialize-a-string
*
* @param string $value
* @return string
*
* @param string $value
* @return string
- * @throws Exception
*/
public static function serializeStringValue( $value ) {
*/
public static function serializeStringValue( $value ) {
- if ( strstr( $value, "\0" ) ) {
- throw new Exception( "Invalid character in CSS string" );
- }
- $value = strtr( $value, [ '\\' => '\\\\', '"' => '\\"' ] );
- $value = preg_replace_callback( '/[\x01-\x1f\x7f-\x9f]/', function ( $match ) {
+ $value = strtr( $value, [ "\0" => "\\fffd ", '\\' => '\\\\', '"' => '\\"' ] );
+ $value = preg_replace_callback( '/[\x01-\x1f\x7f]/', function ( $match ) {
return '\\' . base_convert( ord( $match[0] ), 10, 16 ) . ' ';
}, $value );
return '"' . $value . '"';
return '\\' . base_convert( ord( $match[0] ), 10, 16 ) . ' ';
}, $value );
return '"' . $value . '"';
@@
-424,11
+420,11
@@
class CSSMin {
// is only supported in PHP 5.6. Use a getter method for now.
$urlRegex = '(' .
// Unquoted url
// is only supported in PHP 5.6. Use a getter method for now.
$urlRegex = '(' .
// Unquoted url
- 'url\(\s*(?P<file0>[^\'"][^\?\)]
*
?)(?P<query0>\?[^\)]*?|)\s*\)' .
+ 'url\(\s*(?P<file0>[^\'"][^\?\)]
+
?)(?P<query0>\?[^\)]*?|)\s*\)' .
// Single quoted url
// Single quoted url
- '|url\(\s*\'(?P<file1>[^\?\']
*
?)(?P<query1>\?[^\']*?|)\'\s*\)' .
+ '|url\(\s*\'(?P<file1>[^\?\']
+
?)(?P<query1>\?[^\']*?|)\'\s*\)' .
// Double quoted url
// Double quoted url
- '|url\(\s*"(?P<file2>[^\?"]
*
?)(?P<query2>\?[^"]*?|)"\s*\)' .
+ '|url\(\s*"(?P<file2>[^\?"]
+
?)(?P<query2>\?[^"]*?|)"\s*\)' .
')';
}
return $urlRegex;
')';
}
return $urlRegex;
@@
-446,6
+442,9
@@
class CSSMin {
$match['file'] = $match['file1'];
$match['query'] = $match['query1'];
} else {
$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'];
}
$match['file'] = $match['file2'];
$match['query'] = $match['query2'];
}
@@
-457,6
+456,9
@@
class CSSMin {
$match['file'] = $match['file1'];
$match['query'] = $match['query1'];
} else {
$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'];
}
$match['file'] = $match['file2'];
$match['query'] = $match['query2'];
}
@@
-535,8
+537,8
@@
class CSSMin {
public static function minify( $css ) {
return trim(
str_replace(
public static function minify( $css ) {
return trim(
str_replace(
- [ '; ', ': ', ' {', '{ ', ', ', '} ', ';}' ],
- [ ';', ':', '{', '{', ',', '}', '}' ],
+ [ '; ', ': ', ' {', '{ ', ', ', '} ', ';}'
, '( ', ' )', '[ ', ' ]'
],
+ [ ';', ':', '{', '{', ',', '}', '}'
, '(', ')', '[', ']'
],
preg_replace( [ '/\s+/', '/\/\*.*?\*\//s' ], [ ' ', '' ], $css )
)
);
preg_replace( [ '/\s+/', '/\/\*.*?\*\//s' ], [ ' ', '' ], $css )
)
);