mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop, Mobile: Fixes #2030: Fix handling of URLs that contain single quotes
This commit is contained in:
parent
4e72a8f3a5
commit
60a1f96b4f
@ -50,6 +50,11 @@ function installRule(markdownIt, mdOptions, ruleOptions) {
|
|||||||
hrefAttr = href;
|
hrefAttr = href;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A single quote is valid in a URL but we don't want any because the
|
||||||
|
// href is already enclosed in single quotes.
|
||||||
|
// https://github.com/laurent22/joplin/issues/2030
|
||||||
|
href = href.replace(/'/g, '%27');
|
||||||
|
|
||||||
let js = `${ruleOptions.postMessageSyntax}(${JSON.stringify(href)}); return false;`;
|
let js = `${ruleOptions.postMessageSyntax}(${JSON.stringify(href)}); return false;`;
|
||||||
if (hrefAttr.indexOf('#') === 0 && href.indexOf('#') === 0) js = ''; // If it's an internal anchor, don't add any JS since the webview is going to handle navigating to the right place
|
if (hrefAttr.indexOf('#') === 0 && href.indexOf('#') === 0) js = ''; // If it's an internal anchor, don't add any JS since the webview is going to handle navigating to the right place
|
||||||
return `<a data-from-md ${resourceIdAttr} title='${htmlentities(title)}' href='${hrefAttr}' onclick='${js}' type='${htmlentities(mime)}'>${icon}`;
|
return `<a data-from-md ${resourceIdAttr} title='${htmlentities(title)}' href='${hrefAttr}' onclick='${js}' type='${htmlentities(mime)}'>${icon}`;
|
||||||
|
Loading…
Reference in New Issue
Block a user