Matmarex has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/67263


Change subject: CSSJanus: improve color support
......................................................................

CSSJanus: improve color support

The 'color' rule, and by extension four_notation_color' too, only
understood #rrggbb and named colors. Extended it to match rgb[a](...)
and hsl[a](...) syntax as well.

Bug: 45677
Change-Id: I218a9aa55a86b3d955b92375c1a209fdde312138
---
M includes/libs/CSSJanus.php
M tests/phpunit/includes/libs/CSSJanusTest.php
2 files changed, 11 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/63/67263/1

diff --git a/includes/libs/CSSJanus.php b/includes/libs/CSSJanus.php
index ac33448..46236cd 100644
--- a/includes/libs/CSSJanus.php
+++ b/includes/libs/CSSJanus.php
@@ -96,7 +96,7 @@
                $patterns['ident'] = 
"-?{$patterns['nmstart']}{$patterns['nmchar']}*";
                $patterns['quantity'] = 
"{$patterns['num']}(?:\s*{$patterns['unit']}|{$patterns['ident']})?";
                $patterns['possibly_negative_quantity'] = 
"((?:-?{$patterns['quantity']})|(?:inherit|auto))";
-               $patterns['color'] = "(#?{$patterns['nmchar']}+)";
+               $patterns['color'] = 
"(#?{$patterns['nmchar']}+|(?:rgba?|hsla?)\([ \d.,%-]+\))";
                $patterns['url_chars'] = 
"(?:{$patterns['url_special_chars']}|{$patterns['nonAscii']}|{$patterns['escape']})*";
                $patterns['lookahead_not_open_brace'] = 
"(?!({$patterns['nmchar']}|\r?\n|\s|#|\:|\.|\,|\+|>)*?{)";
                $patterns['lookahead_not_closing_paren'] = 
"(?!{$patterns['url_chars']}?{$patterns['valid_after_uri_chars']}\))";
diff --git a/tests/phpunit/includes/libs/CSSJanusTest.php 
b/tests/phpunit/includes/libs/CSSJanusTest.php
index a1b87f6..37ce26f 100644
--- a/tests/phpunit/includes/libs/CSSJanusTest.php
+++ b/tests/phpunit/includes/libs/CSSJanusTest.php
@@ -151,6 +151,16 @@
                                '#settings td p strong'
                        ),
                        array(
+                               // Test the colors regex
+                               '.foo { border-color: red green blue white }',
+                               '.foo { border-color: red white blue green }',
+                       ),
+                       array(
+                               // Test the colors regex harder
+                               '.foo { border-color: red #f00 rgb(255, 0, 0%) 
rgba(100%, 0, 0, 0) }',
+                               '.foo { border-color: red rgba(100%, 0, 0, 0) 
rgb(255, 0, 0%) #f00 }',
+                       ),
+                       array(
                                // Do not mangle 5 or more values
                                '.foo { -x-unknown: 1 2 3 4 5; }'
                        ),

-- 
To view, visit https://gerrit.wikimedia.org/r/67263
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I218a9aa55a86b3d955b92375c1a209fdde312138
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

Reply via email to