mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-27 15:50:29 +00:00
getTargetDataFromHref: catch error if passed invalid URL
Could trigger this by typing `https://` into the internal link annotation inspector. Bug: T366822 Change-Id: Ie58ded247dbfb6c001d8177953ea148cd82ec03d
This commit is contained in:
parent
291844dbee
commit
b10fb53f8c
|
@ -276,7 +276,13 @@ mw.libs.ve.getTargetDataFromHref = function ( href, doc ) {
|
|||
return data;
|
||||
}
|
||||
|
||||
const url = new URL( href, doc.baseURI );
|
||||
let url;
|
||||
try {
|
||||
url = new URL( href, doc.baseURI );
|
||||
} catch ( e ) {
|
||||
// An invalid URL was provided (e.g. `https://`)
|
||||
return returnExternalData();
|
||||
}
|
||||
|
||||
// Equivalent to `ve.init.platform.getExternalLinkUrlProtocolsRegExp()`, which can not be called here
|
||||
const externalLinkUrlProtocolsRegExp = new RegExp( '^(' + mw.config.get( 'wgUrlProtocols' ) + ')', 'i' );
|
||||
|
|
Loading…
Reference in a new issue