jenkins-bot has submitted this change and it was merged.

Change subject: (Bug 70894) Fix bugs serializing modified wikilinks
......................................................................


(Bug 70894) Fix bugs serializing modified wikilinks

* Fixed serialization of simple category links (strip leading "./" and
  normalize '_' to ' ').

* Fixed detection of isSimpleWikiLink case by normalizing hrefs
  (by replacing '_' to ' ' first).

* Found a missing /g/ flag on a regexp replace. A number
  of previously blacklisted tests change their output because
  of this. The new output is correct.

* Added a new parser test.

Change-Id: I61cf366c481591f21d92983b941bc87e4923cd15
---
M lib/wts.LinkHandler.js
M tests/parserTests-blacklist.js
M tests/parserTests.txt
3 files changed, 33 insertions(+), 22 deletions(-)

Approvals:
  GWicke: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/wts.LinkHandler.js b/lib/wts.LinkHandler.js
index 41ce7c7..a597499 100644
--- a/lib/wts.LinkHandler.js
+++ b/lib/wts.LinkHandler.js
@@ -193,8 +193,8 @@
        var contentString = linkData.content.string,
                canUseSimple = false;
 
-       // Would need to pipe for any non-string content
-       // Preserve unmodified or non-minimal piped links
+       // Would need to pipe for any non-string content.
+       // Preserve unmodified or non-minimal piped links.
        if ( contentString !== undefined
                && ( target.modified
                        || linkData.contentModified
@@ -203,7 +203,7 @@
                // Strip colon escapes from the original target as that is
                // stripped when deriving the content string.
                var strippedTargetValue = target.value.replace(/^:/, ''),
-                       decodedTarget = 
Util.decodeURI(Util.decodeEntities(strippedTargetValue)),
+                       decodedTarget = 
Util.decodeURI(Util.decodeEntities(strippedTargetValue)).replace(/_/g, ' '),
                        hrefHasProto = /^\w+:\/\//.test(linkData.href);
 
                // See if the (normalized) content matches the
@@ -400,7 +400,8 @@
                                        // in the LinkHandler
                                        linkData.content.string = '';
                                } else { // No sort key, will serialize to 
simple link
-                                       linkData.content.string = target.value;
+                                       // Normalize the content string
+                                       linkData.content.string = 
target.value.replace(/^\.\//, '').replace(/_/g, ' ');
                                }
 
                                // Special-case handling for template-affected 
sort keys
@@ -490,7 +491,7 @@
                                if (target.modified || !target.fromsrc) {
                                        linkTarget = 
linkTarget.replace(/^(\.\.?\/)*/, '');
                                        if (!linkData.isInterwiki) {
-                                               linkTarget = 
linkTarget.replace('_', ' ');
+                                               linkTarget = 
linkTarget.replace(/_/g, ' ');
                                        }
                                        escapedRes = 
escapeWikiLinkContentString(linkTarget,
                                                state, node);
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index 0185852..8417639 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -722,10 +722,10 @@
 add("html2html", "Render invalid page names as plain text (bug 51090)", "<p 
data-parsoid='{\"dsr\":[0,141,0,0]}'><span typeof=\"mw:Nowiki\" 
data-parsoid='{\"dsr\":[0,141,8,9]}'>[[./../foo|bar]]\n[[foo�|bar]]\n[[foo/.|bar]]\n[[foo/..|bar]]\n[[foo~~~bar]]\n[[foo>bar]]\n[[foo[bar]]\n[[.]]\n[[..]]\n[[foo././bar]]</span></p>\n\n<p
 data-parsoid='{\"dsr\":[143,423,0,0]}'>[[<span about=\"#mwt34\" 
typeof=\"mw:Transclusion\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"./../foo\"}},\"i\":0}}]}'
 
data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[145,162,null,null]}'>./../foo</span>|bar]]\n[[<span
 about=\"#mwt35\" typeof=\"mw:Transclusion\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo/.\"}},\"i\":0}}]}'
 
data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[171,185,null,null]}'>foo/.</span>|bar]]\n[[<span
 about=\"#mwt36\" typeof=\"mw:Transclusion\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo/..\"}},\"i\":0}}]}'
 
data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[194,209,null,null]}'>foo/..</span>|bar]]\n[[<span
 about=\"#mwt37\" typeof=\"mw:Transclusion\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo~~~~bar\"}},\"i\":0}}]}'
 
data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[218,237,null,null]}'>foo~~~~bar</span>]]\n[[<span
 about=\"#mwt38\" typeof=\"mw:Transclusion\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo>bar\"}},\"i\":0}}]}'
 
data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[242,258,null,null]}'>foo>bar</span>]]\n[[<span
 about=\"#mwt39\" typeof=\"mw:Transclusion\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo././bar\"}},\"i\":0}}]}'
 
data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[263,282,null,null]}'>foo././bar</span>]]\n[[<span
 about=\"#mwt40\" typeof=\"mw:Transclusion\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo{bar\"}},\"i\":0}}]}'
 
data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[287,303,null,null]}'>foo{bar</span>]]\n[[<span
 about=\"#mwt41\" typeof=\"mw:Transclusion\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo}bar\"}},\"i\":0}}]}'
 
data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[308,324,null,null]}'>foo}bar</span>]]\n[[<span
 typeof=\"mw:Transclusion mw:Nowiki\" about=\"#mwt42\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&lt;nowiki>foo[bar&lt;/nowiki>\"}},\"i\":0}}]}'
 
data-parsoid='{\"dsr\":[329,362,null,null],\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]]}'>foo[bar</span>]]\n[[<span
 typeof=\"mw:Transclusion mw:Nowiki\" about=\"#mwt43\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&lt;nowiki>foo]bar&lt;/nowiki>\"}},\"i\":0}}]}'
 
data-parsoid='{\"dsr\":[367,400,null,null],\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]]}'>foo]bar</span>]]\n[[<span
 about=\"#mwt44\" typeof=\"mw:Transclusion\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo&lt;bar\"}},\"i\":0}}]}'
 
data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[405,421,null,null]}'>foo&lt;bar</span>]]</p>\n");
 add("html2html", "Disabled subpages", "<p 
data-parsoid='{\"dsr\":[0,58,0,0]}'>[/index.php?title=/subpage&amp;action=edit&amp;redlink=1
 /subpage]</p>\n");
 add("html2html", "BUG 561: {{/Subpage}}", "<p 
data-parsoid='{\"dsr\":[0,66,0,0]}'>[/index.php?title=Page/Subpage&amp;action=edit&amp;redlink=1
 Page/Subpage]</p>\n");
-add("html2html", "Link to category", "<p 
data-parsoid='{\"dsr\":[0,72,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Category:MediaWiki_User's_Guide\" title=\"Wiki/Category:MediaWiki 
User's Guide\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Category:MediaWiki_User&#39;s_Guide\"},\"sa\":{\"href\":\"wiki/Category:MediaWiki
 User&#39;s_Guide\"},\"dsr\":[0,72,39,2]}'>Category:MediaWiki User's 
Guide</a></p>\n");
-add("html2html", "Simple category", "<p data-parsoid='{\"dsr\":[0,63,0,0]}'><a 
rel=\"mw:WikiLink\" href=\"./Wiki/Category:MediaWiki_User's_Guide\" 
title=\"Wiki/Category:MediaWiki User's Guide\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Category:MediaWiki_User&#39;s_Guide\"},\"sa\":{\"href\":\"wiki/Category:MediaWiki
 User&#39;s_Guide\"},\"dsr\":[0,63,39,2]}'>MediaWiki User's Guide</a></p>");
-add("html2html", "Category with different sort key", "<p 
data-parsoid='{\"dsr\":[0,63,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Category:MediaWiki_User's_Guide\" title=\"Wiki/Category:MediaWiki 
User's Guide\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Category:MediaWiki_User&#39;s_Guide\"},\"sa\":{\"href\":\"wiki/Category:MediaWiki
 User&#39;s_Guide\"},\"dsr\":[0,63,39,2]}'>MediaWiki User's Guide</a></p>");
-add("html2html", "Category with identical sort key", "<p 
data-parsoid='{\"dsr\":[0,63,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Category:MediaWiki_User's_Guide\" title=\"Wiki/Category:MediaWiki 
User's Guide\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Category:MediaWiki_User&#39;s_Guide\"},\"sa\":{\"href\":\"wiki/Category:MediaWiki
 User&#39;s_Guide\"},\"dsr\":[0,63,39,2]}'>MediaWiki User's Guide</a></p>");
+add("html2html", "Link to category", "<p 
data-parsoid='{\"dsr\":[0,72,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Category:MediaWiki_User's_Guide\" title=\"Wiki/Category:MediaWiki 
User's Guide\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Category:MediaWiki_User&#39;s_Guide\"},\"sa\":{\"href\":\"wiki/Category:MediaWiki
 User&#39;s Guide\"},\"dsr\":[0,72,39,2]}'>Category:MediaWiki User's 
Guide</a></p>\n");
+add("html2html", "Simple category", "<p data-parsoid='{\"dsr\":[0,63,0,0]}'><a 
rel=\"mw:WikiLink\" href=\"./Wiki/Category:MediaWiki_User's_Guide\" 
title=\"Wiki/Category:MediaWiki User's Guide\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Category:MediaWiki_User&#39;s_Guide\"},\"sa\":{\"href\":\"wiki/Category:MediaWiki
 User&#39;s Guide\"},\"dsr\":[0,63,39,2]}'>MediaWiki User's Guide</a></p>");
+add("html2html", "Category with different sort key", "<p 
data-parsoid='{\"dsr\":[0,63,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Category:MediaWiki_User's_Guide\" title=\"Wiki/Category:MediaWiki 
User's Guide\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Category:MediaWiki_User&#39;s_Guide\"},\"sa\":{\"href\":\"wiki/Category:MediaWiki
 User&#39;s Guide\"},\"dsr\":[0,63,39,2]}'>MediaWiki User's Guide</a></p>");
+add("html2html", "Category with identical sort key", "<p 
data-parsoid='{\"dsr\":[0,63,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Category:MediaWiki_User's_Guide\" title=\"Wiki/Category:MediaWiki 
User's Guide\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Category:MediaWiki_User&#39;s_Guide\"},\"sa\":{\"href\":\"wiki/Category:MediaWiki
 User&#39;s Guide\"},\"dsr\":[0,63,39,2]}'>MediaWiki User's Guide</a></p>");
 add("html2html", "Category with empty sort key", "<p 
data-parsoid='{\"dsr\":[0,75,0,0]}'><span typeof=\"mw:Nowiki\" 
data-parsoid='{\"dsr\":[0,75,8,9]}'>[[Category:MediaWiki User's Guide|MediaWiki 
User's Guide]]</span></p>");
 add("html2html", "Category with empty sort key and parentheses", "<p 
data-parsoid='{\"dsr\":[0,43,0,0]}'><span typeof=\"mw:Nowiki\" 
data-parsoid='{\"dsr\":[0,43,8,9]}'>[[Category:Foo (bar)|Foo]]</span></p>");
 add("html2html", "Category with link tail", "<p 
data-parsoid='{\"dsr\":[0,39,0,0]}'>123<span typeof=\"mw:Nowiki\" 
data-parsoid='{\"dsr\":[3,36,8,9]}'>[[Category:Foo]]</span>456</p>");
@@ -868,7 +868,7 @@
 add("html2html", "Link to a section of a variant of this title shouldn't be 
parsed as self-link", "<p data-parsoid='{\"dsr\":[0,129,0,0]}'><strong 
class=\"selflink\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[0,38,25,9]}'>Dуна</strong> is a 
self-link while <a rel=\"mw:WikiLink\" href=\"./Wiki/Дуна\" title=\"Wiki/Дуна\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Дуна\"},\"sa\":{\"href\":\"wiki/Дуна\"},\"dsr\":[60,82,12,2]}'>Dunа#Foo</a>
 and <a rel=\"mw:WikiLink\" href=\"./Wiki/Дуна\" title=\"Wiki/Дуна\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Дуна\"},\"sa\":{\"href\":\"wiki/Дуна\"},\"dsr\":[87,109,12,2]}'>Dуна#Foo</a>
 are not self-links.</p>\n");
 add("html2html", "Link to pages in language variants", "<p 
data-parsoid='{\"dsr\":[0,56,0,0]}'>Main Page can be written as <a 
rel=\"mw:WikiLink\" href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main
 Page\"},\"dsr\":[28,56,17,2]}'>Маин Паге</a></p>\n");
 add("html2html", "Multiple links to pages in language variants", "<p 
data-parsoid='{\"dsr\":[0,113,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main
 Page\"},\"dsr\":[0,28,17,2]}'>Main Page</a> can be written as <a 
rel=\"mw:WikiLink\" href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main
 Page\"},\"dsr\":[47,75,17,2]}'>Маин Паге</a> same as <a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main
 Page\"},\"dsr\":[84,112,17,2]}'>Маин Паге</a>.</p>\n");
-add("html2html", "Simple category in language variants", "<p 
data-parsoid='{\"dsr\":[0,65,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Категорија:MediaWiki_User's_Guide\" 
title=\"Wiki/Категорија:MediaWiki User's Guide\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Категорија:MediaWiki_User&#39;s_Guide\"},\"sa\":{\"href\":\"wiki/Категорија:MediaWiki
 User&#39;s_Guide\"},\"dsr\":[0,65,41,2]}'>MediaWiki User's Guide</a></p>");
+add("html2html", "Simple category in language variants", "<p 
data-parsoid='{\"dsr\":[0,65,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Категорија:MediaWiki_User's_Guide\" 
title=\"Wiki/Категорија:MediaWiki User's Guide\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Категорија:MediaWiki_User&#39;s_Guide\"},\"sa\":{\"href\":\"wiki/Категорија:MediaWiki
 User&#39;s Guide\"},\"dsr\":[0,65,41,2]}'>MediaWiki User's Guide</a></p>");
 add("html2html", "Don't convert blue categorylinks to another variant (bug 
33210)", "<p data-parsoid='{\"dsr\":[0,23,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Category:分类\" title=\"Wiki/Category:分类\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Category:分类\"},\"sa\":{\"href\":\"wiki/Category:分类\"},\"dsr\":[0,23,19,2]}'>分类</a></p>");
 add("html2html", "Prevent conversion of links with -{}- tags (language 
variants)", "<p data-parsoid='{\"dsr\":[0,28,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main
 Page\"},\"dsr\":[0,28,17,2]}'>Main Page</a></p>\n");
 add("html2html", "-{}- tags within headlines (within html for 
parserConvert())", "<h2 data-parsoid='{\"dsr\":[0,249,2,2]}'> <span 
class=\"mw-headline\" id=\"-.7BNaslov.7D-\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[3,62,46,7]}'>Naslov</span><span 
class=\"mw-editsection\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[62,246,29,7]}'><span 
class=\"mw-editsection-bracket\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[91,136,37,7]}'>[</span>[/index.php?title=Parser_test&amp;action=edit&amp;section=1
 уреди]<span class=\"mw-editsection-bracket\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[194,239,37,7]}'>]</span></span> 
</h2>\n");
@@ -887,8 +887,8 @@
 add("html2html", "Edit comment with link", "<p 
data-parsoid='{\"dsr\":[0,45,0,0]}'>I like the <a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main
 Page\"},\"dsr\":[11,39,17,2]}'>Main Page</a> a lot</p>");
 add("html2html", "Edit comment with link and link text", "<p 
data-parsoid='{\"dsr\":[0,46,0,0]}'>I like the <a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main
 Page\"},\"dsr\":[11,40,17,2]}'>best pages</a> a lot</p>");
 add("html2html", "Edit comment with link and link text with suffix", "<p 
data-parsoid='{\"dsr\":[0,46,0,0]}'>I like the <a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main
 Page\"},\"dsr\":[11,40,17,2]}'>best pages</a> a lot</p>");
-add("html2html", "Edit comment with section link (non-local, eg in history 
list)", "<p data-parsoid='{\"dsr\":[0,131,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page#External_links\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page#External_links\"},\"sa\":{\"href\":\"wiki/Main
 Page#External_links\"},\"dsr\":[0,35,32,2]}'>→</a>‎<span dir=\"auto\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[36,131,17,7]}'><span 
class=\"autocomment\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[53,102,26,7]}'>External links: </span> 
removed bogus entries</span></p>");
-add("html2html", "Edit comment with section link and text before it 
(non-local, eg in history list)", "<p 
data-parsoid='{\"dsr\":[0,148,0,0]}'>pre-comment text <a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page#External_links\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page#External_links\"},\"sa\":{\"href\":\"wiki/Main
 Page#External_links\"},\"dsr\":[17,52,32,2]}'>→</a>‎<span dir=\"auto\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[53,148,17,7]}'><span 
class=\"autocomment\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[70,119,26,7]}'>External links: </span> 
removed bogus entries</span></p>");
+add("html2html", "Edit comment with section link (non-local, eg in history 
list)", "<p data-parsoid='{\"dsr\":[0,131,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page#External_links\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page#External_links\"},\"sa\":{\"href\":\"wiki/Main
 Page#External links\"},\"dsr\":[0,35,32,2]}'>→</a>‎<span dir=\"auto\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[36,131,17,7]}'><span 
class=\"autocomment\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[53,102,26,7]}'>External links: </span> 
removed bogus entries</span></p>");
+add("html2html", "Edit comment with section link and text before it 
(non-local, eg in history list)", "<p 
data-parsoid='{\"dsr\":[0,148,0,0]}'>pre-comment text <a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page#External_links\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page#External_links\"},\"sa\":{\"href\":\"wiki/Main
 Page#External links\"},\"dsr\":[17,52,32,2]}'>→</a>‎<span dir=\"auto\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[53,148,17,7]}'><span 
class=\"autocomment\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[70,119,26,7]}'>External links: </span> 
removed bogus entries</span></p>");
 add("html2html", "Edit comment with section link (local, eg in diff view)", 
"<p data-parsoid='{\"dsr\":[0,115,0,0]}'>[#External_links →]‎<span dir=\"auto\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[20,115,17,7]}'><span 
class=\"autocomment\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[37,86,26,7]}'>External links: </span> 
removed bogus entries</span></p>");
 add("html2html", "Edit comment with subpage link (bug 14080)", "<p 
data-parsoid='{\"dsr\":[0,57,0,0]}'>Poked at a <a rel=\"mw:WikiLink\" 
href=\"./Wiki/Subpage_test/subpage\" title=\"Wiki/Subpage test/subpage\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Subpage_test/subpage\"},\"sa\":{\"href\":\"wiki/Subpage
 test/subpage\"},\"dsr\":[11,49,28,2]}'>/subpage</a> here...</p>");
 add("html2html", "Edit comment with subpage link and link text (bug 14080)", 
"<p data-parsoid='{\"dsr\":[0,65,0,0]}'>Poked at a <a rel=\"mw:WikiLink\" 
href=\"./Wiki/Subpage_test/subpage\" title=\"Wiki/Subpage test/subpage\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Subpage_test/subpage\"},\"sa\":{\"href\":\"wiki/Subpage
 test/subpage\"},\"dsr\":[11,57,28,2]}'>neat little page</a> here...</p>");
@@ -896,7 +896,7 @@
 add("html2html", "Edit comment with bare anchor link (local, as on diff)", 
"<ol data-parsoid='{\"dsr\":[0,8,0,0]}'><li 
data-parsoid='{\"dsr\":[0,8,1,0]}'>section</li></ol>");
 add("html2html", "Edit comment with bare anchor link (non-local, as on 
history)", "<p data-parsoid='{\"dsr\":[0,35,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page#section\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page#section\"},\"sa\":{\"href\":\"wiki/Main
 Page#section\"},\"dsr\":[0,35,25,2]}'>#section</a></p>");
 add("html2html", "Anchor starting with underscore", "<p 
data-parsoid='{\"dsr\":[0,11,0,0]}'>[#_ref One]</p>\n");
-add("html2html", "Space normalisation on autocomment (bug 22784)", "<p 
data-parsoid='{\"dsr\":[0,106,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page#hello_world\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page#hello_world\"},\"sa\":{\"href\":\"wiki/Main
 Page#hello_world\"},\"dsr\":[0,32,29,2]}'>→</a>‎<span dir=\"auto\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[33,106,17,7]}'><span 
class=\"autocomment\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[50,99,26,7]}'>__hello__world__</span></span></p>");
+add("html2html", "Space normalisation on autocomment (bug 22784)", "<p 
data-parsoid='{\"dsr\":[0,106,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page#hello_world\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page#hello_world\"},\"sa\":{\"href\":\"wiki/Main
 Page#hello world\"},\"dsr\":[0,32,29,2]}'>→</a>‎<span dir=\"auto\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[33,106,17,7]}'><span 
class=\"autocomment\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[50,99,26,7]}'>__hello__world__</span></span></p>");
 add("html2html", "percent-encoding and + signs in comments (Bug 26410)", "<p 
data-parsoid='{\"dsr\":[0,128,0,0]}'>[/index.php?title=ABC3D%25_%2B%2B&amp;action=edit&amp;redlink=1
 ABC3D% ++] [/index.php?title=ABC3D%25_%2B%2B&amp;action=edit&amp;redlink=1 
+%20]</p>");
 add("html2html", "Verify that displaytitle works (bug #22501) no 
displaytitle", "<p data-parsoid='{\"dsr\":[0,11,0,0]}'>Parser test</p>\n\n<p 
data-parsoid='{\"dsr\":[13,38,0,0]}'>this is not the the title</p>\n");
 add("html2html", "Verify that displaytitle works (bug #22501) 
RestrictDisplayTitle=false", "<p 
data-parsoid='{\"dsr\":[0,8,0,0]}'>whatever</p>\n\n<p 
data-parsoid='{\"dsr\":[10,35,0,0]}'>this is not the the title</p>\n");
@@ -1093,7 +1093,7 @@
 add("html2wt", "Bracketed external links with template-generated invalid 
target", "[http:/example.com title]\n");
 add("html2wt", "Bug 2702: Mismatched <i>, <b> and <a> tags are invalid", 
"[http://example.com ''text'']\n[http://example.com '''text''']\n''Something 
''[http://example.com ''in italic'']\n''Something ''[http://example.com 
''mixed''''', even bold''']\n'''''Now '''''[http://example.com 
'''''both''''']\n");
 add("html2wt", "External link containing double-single-quotes in text embedded 
in italics (bug 4598 sanity check)", "''Some ''[http://example.com/ ''pretty 
''italics'' and stuff'']''!''\n");
-add("html2wt", "External link containing double-single-quotes with no space 
separating the url from text in italics", 
"[http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm ''La muerte de 
Casagemas'' (1901) en el sitio de ][[Museo Picasso_(París)|Museo 
Picasso]]<span>.</span>\n");
+add("html2wt", "External link containing double-single-quotes with no space 
separating the url from text in italics", 
"[http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm ''La muerte de 
Casagemas'' (1901) en el sitio de ][[Museo Picasso (París)|Museo 
Picasso]]<span>.</span>\n");
 add("html2wt", "External link with comments in link text", 
"[http://www.google.com Google ]\n");
 add("html2wt", "URL-encoding in URL functions (single parameter)", 
"/index.php?title=Some_page&amp=&\n");
 add("html2wt", "URL-encoding in URL functions (multiple parameters)", 
"/index.php?title=Some_page&q=?&amp=&\n");
@@ -1431,11 +1431,11 @@
 add("html2wt", "Render invalid page names as plain text (bug 51090)", 
"<nowiki>[[./../foo|bar]]\n[[foo�|bar]]\n[[foo/.|bar]]\n[[foo/..|bar]]\n[[foo~~~bar]]\n[[foo>bar]]\n[[foo[bar]]\n[[.]]\n[[..]]\n[[foo././bar]]</nowiki>\n\n[[{{echo|./../foo}}|bar]]\n[[{{echo|foo/.}}|bar]]\n[[{{echo|foo/..}}|bar]]\n[[{{echo|foo~~~~bar}}]]\n[[{{echo|foo>bar}}]]\n[[{{echo|foo././bar}}]]\n[[{{echo|foo{bar}}]]\n[[{{echo|foo}bar}}]]\n[[{{echo|<nowiki>foo[bar</nowiki>}}]]\n[[{{echo|<nowiki>foo]bar</nowiki>}}]]\n[[{{echo|foo<bar}}]]\n");
 add("html2wt", "Disabled subpages", 
"[/index.php?title=/subpage&action=edit&redlink=1 /subpage]\n");
 add("html2wt", "BUG 561: {{/Subpage}}", 
"[/index.php?title=Page/Subpage&action=edit&redlink=1 Page/Subpage]\n");
-add("html2wt", "Link to category", "[[wiki/Category:MediaWiki 
User's_Guide|Category:MediaWiki User's Guide]]\n");
-add("html2wt", "Simple category", "[[wiki/Category:MediaWiki 
User's_Guide|MediaWiki User's Guide]]");
+add("html2wt", "Link to category", "[[wiki/Category:MediaWiki User's 
Guide|Category:MediaWiki User's Guide]]\n");
+add("html2wt", "Simple category", "[[wiki/Category:MediaWiki User's 
Guide|MediaWiki User's Guide]]");
 add("html2wt", "PAGESINCATEGORY invalid title fatal (r33546 fix)", "0\n");
-add("html2wt", "Category with different sort key", "[[wiki/Category:MediaWiki 
User's_Guide|MediaWiki User's Guide]]");
-add("html2wt", "Category with identical sort key", "[[wiki/Category:MediaWiki 
User's_Guide|MediaWiki User's Guide]]");
+add("html2wt", "Category with different sort key", "[[wiki/Category:MediaWiki 
User's Guide|MediaWiki User's Guide]]");
+add("html2wt", "Category with identical sort key", "[[wiki/Category:MediaWiki 
User's Guide|MediaWiki User's Guide]]");
 add("html2wt", "Category with empty sort key", "<nowiki>[[Category:MediaWiki 
User's Guide|MediaWiki User's Guide]]</nowiki>");
 add("html2wt", "Category with empty sort key and parentheses", 
"<nowiki>[[Category:Foo (bar)|Foo]]</nowiki>");
 add("html2wt", "Category with link tail", 
"123<nowiki>[[Category:Foo]]</nowiki>456");
@@ -1659,7 +1659,7 @@
 add("html2wt", "Simple template in language variants", "This is a test 
template\n");
 add("html2wt", "Template with explicit namespace in language variants", "This 
is a test template\n");
 add("html2wt", "Basic test for template parameter in language variants", "This 
is a test template with parameter foo\n");
-add("html2wt", "Simple category in language variants", 
"[[wiki/Категорија:MediaWiki User's_Guide|MediaWiki User's Guide]]");
+add("html2wt", "Simple category in language variants", 
"[[wiki/Категорија:MediaWiki User's Guide|MediaWiki User's Guide]]");
 add("html2wt", "Don't convert blue categorylinks to another variant (bug 
33210)", "[[wiki/Category:分类|分类]]");
 add("html2wt", "Stripping -{}- tags (language variants)", "Latin proverb: Ne 
nuntium necare\n");
 add("html2wt", "Prevent conversion with -{}- tags (language variants)", 
"Латински: Ne nuntium necare\n");
@@ -1715,8 +1715,8 @@
 add("html2wt", "Edit comment with link", "I like the [[wiki/Main Page|Main 
Page]] a lot");
 add("html2wt", "Edit comment with link and link text", "I like the [[wiki/Main 
Page|best pages]] a lot");
 add("html2wt", "Edit comment with link and link text with suffix", "I like the 
[[wiki/Main Page|best pages]] a lot");
-add("html2wt", "Edit comment with section link (non-local, eg in history 
list)", "[[wiki/Main Page#External_links|→]]‎<span dir=\"auto\"><span 
class=\"autocomment\">External links: </span> removed bogus entries</span>");
-add("html2wt", "Edit comment with section link and text before it (non-local, 
eg in history list)", "pre-comment text [[wiki/Main 
Page#External_links|→]]‎<span dir=\"auto\"><span class=\"autocomment\">External 
links: </span> removed bogus entries</span>");
+add("html2wt", "Edit comment with section link (non-local, eg in history 
list)", "[[wiki/Main Page#External links|→]]‎<span dir=\"auto\"><span 
class=\"autocomment\">External links: </span> removed bogus entries</span>");
+add("html2wt", "Edit comment with section link and text before it (non-local, 
eg in history list)", "pre-comment text [[wiki/Main Page#External 
links|→]]‎<span dir=\"auto\"><span class=\"autocomment\">External links: 
</span> removed bogus entries</span>");
 add("html2wt", "Edit comment with section link (local, eg in diff view)", 
"[#External_links →]‎<span dir=\"auto\"><span class=\"autocomment\">External 
links: </span> removed bogus entries</span>");
 add("html2wt", "Edit comment with subpage link (bug 14080)", "Poked at a 
[[wiki/Subpage test/subpage|/subpage]] here...");
 add("html2wt", "Edit comment with subpage link and link text (bug 14080)", 
"Poked at a [[wiki/Subpage test/subpage|neat little page]] here...");
@@ -1724,7 +1724,7 @@
 add("html2wt", "Edit comment with bare anchor link (local, as on diff)", 
"#section");
 add("html2wt", "Edit comment with bare anchor link (non-local, as on 
history)", "[[wiki/Main Page#section|#section]]");
 add("html2wt", "Anchor starting with underscore", "[#_ref One]\n");
-add("html2wt", "Space normalisation on autocomment (bug 22784)", "[[wiki/Main 
Page#hello_world|→]]‎<span dir=\"auto\"><span 
class=\"autocomment\">__hello__world__</span></span>");
+add("html2wt", "Space normalisation on autocomment (bug 22784)", "[[wiki/Main 
Page#hello world|→]]‎<span dir=\"auto\"><span 
class=\"autocomment\">__hello__world__</span></span>");
 add("html2wt", "percent-encoding and + signs in comments (Bug 26410)", 
"[/index.php?title=ABC3D%25_%2B%2B&action=edit&redlink=1 ABC3D% ++] 
[/index.php?title=ABC3D%25_%2B%2B&action=edit&redlink=1 +%20]");
 add("html2wt", "Verify that displaytitle works (bug #22501) no displaytitle", 
"Parser test\n\nthis is not the the title\n");
 add("html2wt", "Verify that displaytitle works (bug #22501) 
RestrictDisplayTitle=false", "whatever\n\nthis is not the the title\n");
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 41d1536..8528c77 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -12599,6 +12599,16 @@
 !! end
 
 !! test
+Normalize hrefs properly before testing for invalid link targets (bug 70894)
+!! options
+parsoid=html2wt
+!! html
+<link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
+!! wikitext
+[[Category:Toxine bactérienne]]
+!! end
+
+!! test
 Parsoid: Defaultsort
 !! options
 parsoid

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I61cf366c481591f21d92983b941bc87e4923cd15
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Marcoil <[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