Fomafix has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/393256 )

Change subject: Armor against French spaces detection in HTML attributes
......................................................................

Armor against French spaces detection in HTML attributes

This change also solves T13874 in a generic way.

Bug: T5158
Change-Id: Id8cdb887182f346acab2d108836ce201626848af
---
M includes/parser/Parser.php
M includes/parser/Sanitizer.php
M tests/parser/parserTests.txt
3 files changed, 17 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/56/393256/1

diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 3548da9..d9d2b99 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -1339,7 +1339,6 @@
                        '/(.) (?=\\?|:|;|!|%|\\302\\273)/' => '\\1 ',
                        # french spaces, Guillemet-right
                        '/(\\302\\253) /' => '\\1 ',
-                       '/ (!\s*important)/' => ' \\1', # Beware of CSS 
magic word !important, T13874.
                ];
                $text = preg_replace( array_keys( $fixtags ), array_values( 
$fixtags ), $text );
 
diff --git a/includes/parser/Sanitizer.php b/includes/parser/Sanitizer.php
index 20fee2d..a0ee8a0 100644
--- a/includes/parser/Sanitizer.php
+++ b/includes/parser/Sanitizer.php
@@ -1158,6 +1158,15 @@
                        '|'    => '|',
                        '__'   => '__',
                ] );
+               # Armor against French spaces detection
+               $fixtags = [
+                       # French spaces, last one Guillemet-left
+                       # only if there is something before the space
+                       '/(.) (?=\\?|:|;|!|%|\\302\\273)/' => '\\1 ',
+                       # french spaces, Guillemet-right
+                       '/(\\302\\253) /' => '\\1 ',
+               ];
+               $encValue = preg_replace( array_keys( $fixtags ), array_values( 
$fixtags ), $encValue );
 
                # Stupid hack
                $encValue = preg_replace_callback(
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index 7af3a36..cb3709e 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -30144,3 +30144,11 @@
 
 </section><section data-mw-section-id="2"><h1 id="d"> d </h1></section>
 !! end
+
+T5158: Test for French spaces in attributes
+!! wikitext
+<br style=" clear : both ; " />
+!! html/php
+<p><br style="clear&#32;: both&#32;;" />
+</p>
+!! end

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id8cdb887182f346acab2d108836ce201626848af
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Fomafix <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to