Merge "Skin: Make skins aware of their registered skin name"
[lhc/web/wiklou.git] / includes / libs / CSSMin.php
index cd80066..ee88d0d 100644 (file)
@@ -142,7 +142,15 @@ class CSSMin {
                if ( preg_match( '/^[\r\n\t\x20-\x7e]+$/', $contents ) ) {
                        // Do not base64-encode non-binary files (sane SVGs).
                        // (This often produces longer URLs, but they compress better, yielding a net smaller size.)
-                       $uri = 'data:' . $type . ',' . rawurlencode( $contents );
+                       $encoded = rawurlencode( $contents );
+                       // Unencode some things that don't need to be encoded, to make the encoding smaller
+                       $encoded = strtr( $encoded, [
+                               '%20' => ' ', // Unencode spaces
+                               '%2F' => '/', // Unencode slashes
+                               '%3A' => ':', // Unencode colons
+                               '%3D' => '=', // Unencode equals signs
+                       ] );
+                       $uri = 'data:' . $type . ',' . $encoded;
                        if ( !$ie8Compat || strlen( $uri ) < self::DATA_URI_SIZE_LIMIT ) {
                                return $uri;
                        }