DLynch has uploaded a new change for review.
https://gerrit.wikimedia.org/r/293332
Change subject: Decode encoded link titles when generating them from text
......................................................................
Decode encoded link titles when generating them from text
Percent-encoded characters are forbidden in titles. Copying URLs around will
tend to wind up when them percent-encoded when you paste. Therefore, when
trying to build a title from a pasted link, decode it first.
Change-Id: Ia0abcb2d903b04d99c7db16eb0a5962480b138d5
---
M modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js
1 file changed, 5 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/32/293332/1
diff --git a/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js
b/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js
index fafa709..e69b641 100644
--- a/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js
+++ b/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js
@@ -117,7 +117,11 @@
// in which case it's preceded by one or more instances of "./" or
"../", so strip those
matches = href.match( /^((?:\.\.?\/)*)(.*)$/ );
- return { title: matches[ 2 ], hrefPrefix: matches[ 1 ], isInternal:
isInternal };
+ // Percent-encoded characters are forbidden in titles... but if we're
+ // copy/pasting URLs around, they're likely to wind up encoded at this
+ // point. So decode them, otherwise this is going to cause failures
+ // elsewhere.
+ return { title: decodeURIComponent( matches[ 2 ] ), hrefPrefix:
matches[ 1 ], isInternal: isInternal };
};
ve.dm.MWInternalLinkAnnotation.static.toDomElements = function () {
--
To view, visit https://gerrit.wikimedia.org/r/293332
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia0abcb2d903b04d99c7db16eb0a5962480b138d5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits