Skip to content

Commit

Permalink
Desktop, Mobile: Fixes laurent22#2030: Fix handling of URLs that cont…
Browse files Browse the repository at this point in the history
…ain single quotes
  • Loading branch information
laurent22 authored and scoroi committed Nov 10, 2019
1 parent 602712a commit e87922d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ReactNativeClient/lib/renderers/MdToHtml/rules/link_open.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ function installRule(markdownIt, mdOptions, ruleOptions) {
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;`;
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}`;
Expand Down

0 comments on commit e87922d

Please sign in to comment.