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

Change subject: Make multiple colons escaping interlanguage links invalid
......................................................................


Make multiple colons escaping interlanguage links invalid

Depends-On: Icabd34bbf15781bb891bd8e0c079d1a65eb28595
Change-Id: I62c48afdeb7f237ab196e528b87cd935171026ec
---
M lib/wt2html/tt/LinkHandler.js
M tests/parserTests.txt
2 files changed, 23 insertions(+), 0 deletions(-)

Approvals:
  C. Scott Ananian: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/wt2html/tt/LinkHandler.js b/lib/wt2html/tt/LinkHandler.js
index ab12d65..2e65428 100644
--- a/lib/wt2html/tt/LinkHandler.js
+++ b/lib/wt2html/tt/LinkHandler.js
@@ -84,6 +84,10 @@
                // remove the colon escape
                info.href = info.href.substr(1);
        }
+       if (/^:/.test(info.href)) {
+               // This will get caught by the caller, and mark the target as 
invalid
+               throw new Error('Multiple colons prefixing href.');
+       }
 
        // strip ./ prefixes
        info.href = info.href.replace(/^(?:\.\/)+/, '');
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 95df91d..f55306f 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -8793,6 +8793,25 @@
 <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese"; 
title="zh:Chinese"> zh : Chinese </a></p>
 !! end
 
+!! test
+Multiple colons escaping interlanguage links
+!! options
+parsoid=wt2html
+!! wikitext
+[[:es:Spanish]]
+[[::es:Spanish]]
+[[:::es:Spanish]]
+!! html/php
+<p><a href="http://es.wikipedia.org/wiki/Spanish"; class="extiw" 
title="es:Spanish">es:Spanish</a>
+[[::es:Spanish]]
+[[:::es:Spanish]]
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish"; 
title="es:Spanish">es:Spanish</a>
+[[::es:Spanish]]
+[[:::es:Spanish]]</p>
+!! end
+
 ## parsoid html2wt will normalize the space to _
 !! test
 Space and question mark encoding in interlanguage links (T95473)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I62c48afdeb7f237ab196e528b87cd935171026ec
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: C. Scott Ananian <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to