jenkins-bot has submitted this change and it was merged.
Change subject: Bug 48081: Fix relative internal wiki link labels
......................................................................
Bug 48081: Fix relative internal wiki link labels
Relative internal wiki links were showing the wikitext rather than their
traditional label.
Also, a path in getWikiLinkTargetInfo() was not being reached when href
was being normalized.
Change-Id: Ic5eb06b8b4992e5bcc97dceff0ab67d4ff356deb
---
M js/lib/ext.core.LinkHandler.js
M js/lib/mediawiki.WikitextSerializer.js
M js/tests/parserTests-blacklist.js
3 files changed, 23 insertions(+), 2 deletions(-)
Approvals:
GWicke: Looks good to me, approved
jenkins-bot: Verified
diff --git a/js/lib/ext.core.LinkHandler.js b/js/lib/ext.core.LinkHandler.js
index 71db862..d30005c 100644
--- a/js/lib/ext.core.LinkHandler.js
+++ b/js/lib/ext.core.LinkHandler.js
@@ -274,7 +274,8 @@
var title = target.title,
attribs = token.attribs,
newAttrData = buildLinkAttrs(attribs, true, null, [new
KV('rel', 'mw:WikiLink')]),
- content = newAttrData.content;
+ content = newAttrData.content,
+ env = this.manager.env;
// Set attribs and dataAttribs
newTk.attribs = newAttrData.attribs;
newTk.dataAttribs = Util.clone(token.dataAttribs);
@@ -304,6 +305,24 @@
// Strip leading colon
morecontent = morecontent.replace(/^:/, '');
+ // Try to match labeling in core
+ if ( env.page.meta.ns === undefined ||
env.conf.wiki.namespacesWithSubpages[ env.page.meta.ns ] ) {
+ var match = morecontent.match( /^\/(.*)\/$/ );
+ if ( match ) {
+ morecontent = match[1];
+ } else if ( /^\.\.\//.test( morecontent ) ) {
+ // If a there's a trailing slash, don't resolve
title
+ // making sure the second to last character
isn't a
+ // forward slash, for cases like: ../../////
+ match = morecontent.match( /^(\.\.\/)+(.*[^/])\/$/ );
+ if ( match ) {
+ morecontent = match[2];
+ } else if ( env.page.meta.ns !== undefined ) {
+ morecontent = env.resolveTitle(
morecontent, env.page.meta.ns );
+ }
+ }
+ }
+
content = [ morecontent ];
}
return content;
diff --git a/js/lib/mediawiki.WikitextSerializer.js
b/js/lib/mediawiki.WikitextSerializer.js
index 74421ac..d9048b2 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -1578,6 +1578,9 @@
// target, either shadowed or actual.
( contentString ===
Util.decodeURI(Util.decodeEntities(strippedTargetValue)) ||
+ // try wrapped in forward
slashes in case they were stripped
+ ('/' + contentString + '/') ===
+
Util.decodeURI(Util.decodeEntities(strippedTargetValue)) ||
contentString === linkData.href
||
// normalize without
underscores for
// comparison with target.value
and strip
diff --git a/js/tests/parserTests-blacklist.js
b/js/tests/parserTests-blacklist.js
index 5b1ce38..5911743 100644
--- a/js/tests/parserTests-blacklist.js
+++ b/js/tests/parserTests-blacklist.js
@@ -241,7 +241,6 @@
add("wt2html", "Parsoid-specific image handling - thumbnail with halign,
valign, and caption");
add("wt2html", "Parsoid-specific image handling - thumbnail with specific
size, halign, valign, and caption");
add("wt2html", "Parsoid-specific image handling - framed image with specific
size, halign, valign, and caption");
-add("wt2html", "Subpage noslash link");
add("wt2html", "BUG 561: {{/Subpage}}");
add("wt2html", "Simple category");
add("wt2html", "PAGESINCATEGORY invalid title fatal (r33546 fix)");
--
To view, visit https://gerrit.wikimedia.org/r/70100
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic5eb06b8b4992e5bcc97dceff0ab67d4ff356deb
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits