Subramanya Sastry has uploaded a new change for review.

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

Change subject: (Bug 63636): Handle multiple colons in subpage-supporting 
namespaces
......................................................................

(Bug 63636): Handle multiple colons in subpage-supporting namespaces

* Added new test which fails html2wt mode because of a leading "./"
  prefix added (to be investigated separately -- failure is unrelated
  to this patch).

Change-Id: I32a97fa506ab7eee84a41cf371c6d5cd4bf2ef64
---
M lib/mediawiki.Title.js
M tests/parserTests-blacklist.js
M tests/parserTests.txt
3 files changed, 21 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/70/124370/1

diff --git a/lib/mediawiki.Title.js b/lib/mediawiki.Title.js
index 64491d4..e3ad121 100644
--- a/lib/mediawiki.Title.js
+++ b/lib/mediawiki.Title.js
@@ -20,9 +20,15 @@
 
        // If the title is relative, the resolved key will contain the namespace
        // from env.page.name, so we need to take it out.
-       if ( env.conf.wiki.namespacesWithSubpages[ns] &&
-            /^(\.\.\/)+|(\/)/.test( key ) ) {
-               this.key = this.key.split( ':', 2 ).pop();
+       if ( env.conf.wiki.namespacesWithSubpages[ns] && 
/^(\.\.\/)+|(\/)/.test( key ) ) {
+               var keyParts = this.key.split(':', 2);
+               // Some titles can have subpages enabled, have a "/" in the name
+               // and have a namespace-like string in it
+               // Ex: Utilisateur:Steven De Oliveira/Brouillon/007 : Quitte ou 
double
+               // from bug 63636
+               if (env.conf.wiki.namespaceIds[keyParts[1]] === ns) {
+                       this.key = keyParts.pop();
+               }
        }
 
        this.ns = new Namespace( ns, env );
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index 8ed5986..0276902 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -1359,6 +1359,7 @@
 add("html2wt", "Internal link with en linktrail: no apostrophes (bug 27473)", 
"<a href=\"/index.php?title=Something&action=edit&redlink=1\" class=\"new\" 
title=\"Something (page does not exist)\">Something</a>'nice\n");
 add("html2wt", "Internal link with ca linktrail with apostrophes (bug 27473)", 
"<a href=\"/index.php?title=Something&action=edit&redlink=1\" class=\"new\" 
title=\"Something (encara no existeix)\">Something'nice</a>\n");
 add("html2wt", "Internal link with kaa linktrail with apostrophes (bug 
27473)", "<a href=\"/index.php?title=Something&action=edit&redlink=1\" 
class=\"new\" title=\"Something (bet ele 
jaratılmag'an)\">Something'nice</a>\n");
+add("html2wt", "Link with multiple \":\" in a subpage-supporting namespace 
(bug 63636)", "[[./User:Foo/Test/63636:Bar|Test]]\n");
 add("html2wt", "Internal link with is link prefix", "Aðrir <a 
href=\"/wiki/S%C3%B6fnu%C3%B0ur\" title=\"Söfnuður\">mótmælendasöfnuðir</a> 
og\n");
 add("html2wt", "Internal link with is link trail and link prefix", "<a 
href=\"/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA\" 
title=\"Mótmælendatrú\">xxxar</a>\n<a 
href=\"/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA\" 
title=\"Mótmælendatrú\">mótmælendatrúar</a>\n<a 
href=\"/wiki/S%C3%B6fnu%C3%B0ur\" title=\"Söfnuður\">mótmælendasöfnuður</a>\n<a 
href=\"/wiki/S%C3%B6fnu%C3%B0ur\" title=\"Söfnuður\">mótmælendasöfnuðir</a>\n<a 
href=\"/wiki/S%C3%B6fnu%C3%B0ur\" 
title=\"Söfnuður\">mótmælendasöfnuðirxxx</a>\n");
 add("html2wt", "Parsoid-centric test: Whitespace in ext- and wiki-links should 
be preserved", "<a href=\"/index.php?title=Foo&action=edit&redlink=1\" 
class=\"new\" title=\"Foo (page does not exist)\">  bar</a>\n\n<a 
href=\"/index.php?title=Foo&action=edit&redlink=1\" class=\"new\" title=\"Foo 
(page does not exist)\">  ''bar''</a>\n\n[http://wp.org foo]\n\n[http://wp.org 
''foo'']\n");
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 496fba4..a78bbaf 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -5789,6 +5789,17 @@
 !! end
 
 !! test
+Link with multiple ":" in a subpage-supporting namespace (bug 63636)
+!! wikitext
+[[User:Foo/Test/63636:Bar|Test]]
+!! html/php
+<p><a href="./User:Foo/Test/63636:Bar">Test</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar">Test</a></p>
+!! end
+
+!! test
 1. Interaction of linktrail and template encapsulation
 !! options
 parsoid

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I32a97fa506ab7eee84a41cf371c6d5cd4bf2ef64
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>

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

Reply via email to