Matmarex has uploaded a new change for review.
https://gerrit.wikimedia.org/r/67262
Change subject: CSSJanus: don't mangle 5+ consecutive numeric values
......................................................................
CSSJanus: don't mangle 5+ consecutive numeric values
Don't mangle 5+ consecutive numeric values in the
'four_notation_quantity' and 'four_notation_color' rules. This
prevents box-shadow rules from being utterly broken in RTL (but still
doesn't flip them properly).
Bug: 45677
Change-Id: I16cb9e171a79c6f299b40fa02908b0c045e3c474
---
M includes/libs/CSSJanus.php
M tests/phpunit/includes/libs/CSSJanusTest.php
2 files changed, 7 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/62/67262/1
diff --git a/includes/libs/CSSJanus.php b/includes/libs/CSSJanus.php
index fb1e9a4..ac33448 100644
--- a/includes/libs/CSSJanus.php
+++ b/includes/libs/CSSJanus.php
@@ -113,8 +113,8 @@
$patterns['rtl_in_url'] =
"/{$patterns['lookbehind_not_letter']}(rtl){$patterns['lookahead_for_closing_paren']}/i";
$patterns['cursor_east'] =
"/{$patterns['lookbehind_not_letter']}([ns]?)e-resize/";
$patterns['cursor_west'] =
"/{$patterns['lookbehind_not_letter']}([ns]?)w-resize/";
- $patterns['four_notation_quantity'] =
"/{$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}/i";
- $patterns['four_notation_color'] =
"/(-color\s*:\s*){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}/i";
+ $patterns['four_notation_quantity'] =
"/(:\s*){$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}(\s*[;}])/i";
+ $patterns['four_notation_color'] =
"/(-color\s*:\s*){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}(\s*[;}])/i";
// The two regexes below are parenthesized differently then in
the original implementation to make the
// callback's job more straightforward
$patterns['bg_horizontal_percentage'] =
"/(background(?:-position)?\s*:\s*[^%]*?)(-?{$patterns['num']})(%\s*(?:{$patterns['quantity']}|{$patterns['ident']}))/";
@@ -257,8 +257,8 @@
* @return string
*/
private static function fixFourPartNotation( $css ) {
- $css = preg_replace( self::$patterns['four_notation_quantity'],
'$1$2$7$4$5$6$3', $css );
- $css = preg_replace( self::$patterns['four_notation_color'],
'$1$2$3$8$5$6$7$4', $css );
+ $css = preg_replace( self::$patterns['four_notation_quantity'],
'$1$2$3$8$5$6$7$4$9', $css );
+ $css = preg_replace( self::$patterns['four_notation_color'],
'$1$2$3$8$5$6$7$4$9', $css );
return $css;
}
diff --git a/tests/phpunit/includes/libs/CSSJanusTest.php
b/tests/phpunit/includes/libs/CSSJanusTest.php
index 632eb52..a1b87f6 100644
--- a/tests/phpunit/includes/libs/CSSJanusTest.php
+++ b/tests/phpunit/includes/libs/CSSJanusTest.php
@@ -151,14 +151,11 @@
'#settings td p strong'
),
array(
- # Not sure how 4+ values should behave,
- # testing to make sure changes are detected
- '.foo { x-unknown: 1 2 3 4 5; }',
- '.foo { x-unknown: 1 4 3 2 5; }',
+ // Do not mangle 5 or more values
+ '.foo { -x-unknown: 1 2 3 4 5; }'
),
array(
- '.foo { x-unknown: 1 2 3 4 5 6; }',
- '.foo { x-unknown: 1 4 3 2 5 6; }',
+ '.foo { -x-unknown: 1 2 3 4 5 6; }'
),
// Shorthand / Three notation
--
To view, visit https://gerrit.wikimedia.org/r/67262
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I16cb9e171a79c6f299b40fa02908b0c045e3c474
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Matmarex <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits