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 "Move most User::clearAllNotifications() logic to WatchedItemStore"
[lhc/web/wiklou.git]
/
includes
/
libs
/
CSSMin.php
diff --git
a/includes/libs/CSSMin.php
b/includes/libs/CSSMin.php
index
a9cbba2
..
3d1c8b8
100644
(file)
--- a/
includes/libs/CSSMin.php
+++ b/
includes/libs/CSSMin.php
@@
-132,6
+132,9
@@
class CSSMin {
*/
public static function encodeStringAsDataURI( $contents, $type, $ie8Compat = true ) {
// Try #1: Non-encoded data URI
*/
public static function encodeStringAsDataURI( $contents, $type, $ie8Compat = true ) {
// Try #1: Non-encoded data URI
+
+ // Remove XML declaration, it's not needed with data URI usage
+ $contents = preg_replace( "/<\\?xml.*?\\?>/", '', $contents );
// The regular expression matches ASCII whitespace and printable characters.
if ( preg_match( '/^[\r\n\t\x20-\x7e]+$/', $contents ) ) {
// Do not base64-encode non-binary files (sane SVGs).
// The regular expression matches ASCII whitespace and printable characters.
if ( preg_match( '/^[\r\n\t\x20-\x7e]+$/', $contents ) ) {
// Do not base64-encode non-binary files (sane SVGs).
@@
-143,7
+146,15
@@
class CSSMin {
'%2F' => '/', // Unencode slashes
'%3A' => ':', // Unencode colons
'%3D' => '=', // Unencode equals signs
'%2F' => '/', // Unencode slashes
'%3A' => ':', // Unencode colons
'%3D' => '=', // Unencode equals signs
+ '%0A' => ' ', // Change newlines to spaces
+ '%0D' => ' ', // Change carriage returns to spaces
+ '%09' => ' ', // Change tabs to spaces
] );
] );
+ // Consolidate runs of multiple spaces in a row
+ $encoded = preg_replace( '/ {2,}/', ' ', $encoded );
+ // Remove leading and trailing spaces
+ $encoded = preg_replace( '/^ | $/', '', $encoded );
+
$uri = 'data:' . $type . ',' . $encoded;
if ( !$ie8Compat || strlen( $uri ) < self::DATA_URI_SIZE_LIMIT ) {
return $uri;
$uri = 'data:' . $type . ',' . $encoded;
if ( !$ie8Compat || strlen( $uri ) < self::DATA_URI_SIZE_LIMIT ) {
return $uri;
@@
-524,8
+535,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 )
)
);