VolkerE has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/403092 )
Change subject: Re-introduce CSSMin: Mangle whitespace in embedded SVGs
......................................................................
Re-introduce CSSMin: Mangle whitespace in embedded SVGs
Convert newlines and tabs to spaces (which can be unencoded),
and consolidate runs of multiple spaces into a single space.
Also remove any leading and trailing spaces that might result
(most files end in a newline, for example).
Follow-up to Iddc98332d. This was reverted as dependency for the
original issues causing patch, but works perfectly fine.
Bug: T175318
Change-Id: Ic25d73caeb42ba7a32ef304806d401047b5a1997
---
M includes/libs/CSSMin.php
M tests/phpunit/includes/libs/CSSMinTest.php
2 files changed, 9 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/92/403092/1
diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php
index a9cbba2..e85f02d 100644
--- a/includes/libs/CSSMin.php
+++ b/includes/libs/CSSMin.php
@@ -143,7 +143,14 @@
'%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;
diff --git a/tests/phpunit/includes/libs/CSSMinTest.php
b/tests/phpunit/includes/libs/CSSMinTest.php
index a6efc85..81ceb59 100644
--- a/tests/phpunit/includes/libs/CSSMinTest.php
+++ b/tests/phpunit/includes/libs/CSSMinTest.php
@@ -271,9 +271,9 @@
// data: URIs for red.gif, green.gif, circle.svg
$red =
'data:image/gif;base64,R0lGODlhAQABAIAAAP8AADAAACwAAAAAAQABAAACAkQBADs=';
$green =
'data:image/gif;base64,R0lGODlhAQABAIAAAACAADAAACwAAAAAAQABAAACAkQBADs=';
- $svg = 'data:image/svg+xml,%3C%3Fxml version=%221.0%22
encoding=%22UTF-8%22%3F%3E%0A'
+ $svg = 'data:image/svg+xml,%3C%3Fxml version=%221.0%22
encoding=%22UTF-8%22%3F%3E '
. '%3Csvg xmlns=%22http://www.w3.org/2000/svg%22
width=%228%22 height='
- . '%228%22%3E%0A%09%3Ccircle cx=%224%22 cy=%224%22
r=%222%22/%3E%0A%3C/svg%3E%0A';
+ . '%228%22%3E %3Ccircle cx=%224%22 cy=%224%22
r=%222%22/%3E %3C/svg%3E';
// phpcs:disable Generic.Files.LineLength
return [
--
To view, visit https://gerrit.wikimedia.org/r/403092
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic25d73caeb42ba7a32ef304806d401047b5a1997
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: VolkerE <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits