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
This commit is contained in:
David Lynch 2016-06-08 17:26:27 +01:00
parent 953422a605
commit cc78cb2d06

View file

@ -117,7 +117,15 @@ ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref = function ( href, d
// 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: ve.safeDecodeURIComponent( matches[ 2 ] ),
hrefPrefix: matches[ 1 ],
isInternal: isInternal
};
};
ve.dm.MWInternalLinkAnnotation.static.toDomElements = function () {