jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/391135 )

Change subject: Sanitizer::safeEncodeAttribute(): also encode ]
......................................................................


Sanitizer::safeEncodeAttribute(): also encode ]

...so that it wouldn't break wikilinks, too.

Bug: T29694
Bug: T51672
Bug: T72875
Change-Id: I189bdefbc9034cf8d221a89d7158195de1c0fa6c
---
M includes/parser/Sanitizer.php
M tests/parser/parserTests.txt
2 files changed, 27 insertions(+), 2 deletions(-)

Approvals:
  Subramanya Sastry: Looks good to me, but someone else must approve
  C. Scott Ananian: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/parser/Sanitizer.php b/includes/parser/Sanitizer.php
index 4c99677..46cf2a5 100644
--- a/includes/parser/Sanitizer.php
+++ b/includes/parser/Sanitizer.php
@@ -1150,6 +1150,7 @@
                        '{'    => '{',
                        '}'    => '}', // prevent unpaired language 
conversion syntax
                        '['    => '[',
+                       ']'    => ']',
                        "''"   => '''',
                        'ISBN' => 'ISBN',
                        'RFC'  => 'RFC',
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index a505cde..6e9f944 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -17774,7 +17774,7 @@
 !! wikitext
 <div title="[[Main Page]]"></div>
 !! html
-<div title="&#91;&#91;Main Page]]"></div>
+<div title="&#91;&#91;Main Page&#93;&#93;"></div>
 
 !! end
 
@@ -17837,7 +17837,7 @@
 !! wikitext
 <div title="[http://example.com/ link]"></div>
 !! html
-<div title="&#91;http&#58;//example.com/ link]"></div>
+<div title="&#91;http&#58;//example.com/ link&#93;"></div>
 
 !! end
 
@@ -29705,3 +29705,27 @@
 <p><a href="#Foo_bar">#Foo&#160;bar</a>
 </p>
 !! end
+
+!! test
+T51672: Test for brackets in attributes of elements in external link texts
+!! wikitext
+[http://example.com/ link <span title="title with [brackets]">span</span>]
+[http://example.com/ link <span title="title with 
&#91;brackets&#93;">span</span>]
+
+!! html/php
+<p><a rel="nofollow" class="external text" href="http://example.com/";>link 
<span title="title with &#91;brackets&#93;">span</span></a>
+<a rel="nofollow" class="external text" href="http://example.com/";>link <span 
title="title with &#91;brackets&#93;">span</span></a>
+</p>
+!! end
+
+!! test
+T72875: Test for brackets in attributes of elements in internal link texts
+!! wikitext
+[[Foo|link <span title="title with [[double brackets]]">span</span>]]
+[[Foo|link <span title="title with &#91;&#91;double 
brackets&#93;&#93;">span</span>]]
+
+!! html/php
+<p><a href="/wiki/Foo" title="Foo">link <span title="title with 
&#91;&#91;double brackets&#93;&#93;">span</span></a>
+<a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double 
brackets&#93;&#93;">span</span></a>
+</p>
+!! end

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I189bdefbc9034cf8d221a89d7158195de1c0fa6c
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MaxSem <maxsem.w...@gmail.com>
Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org>
Gerrit-Reviewer: Brian Wolff <bawolff...@gmail.com>
Gerrit-Reviewer: C. Scott Ananian <canan...@wikimedia.org>
Gerrit-Reviewer: Fomafix <foma...@googlemail.com>
Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com>
Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to