diff --git a/ReactNativeClient/lib/markdownUtils.js b/ReactNativeClient/lib/markdownUtils.js index 82df8dfe0..34fcc0fe6 100644 --- a/ReactNativeClient/lib/markdownUtils.js +++ b/ReactNativeClient/lib/markdownUtils.js @@ -9,11 +9,6 @@ const listRegex = /^(\s*)([*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/; const emptyListRegex = /^(\s*)([*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/; const markdownUtils = { - // Not really escaping because that's not supported by marked.js - escapeLinkText(text) { - return text.replace(/(\[|\]|\(|\))/g, '_'); - }, - // Titles for markdown links only need escaping for [ and ] escapeTitleText(text) { return text.replace(/(\[|\])/g, '\\$1'); diff --git a/ReactNativeClient/lib/models/Resource.js b/ReactNativeClient/lib/models/Resource.js index 1737278d0..daf625c60 100644 --- a/ReactNativeClient/lib/models/Resource.js +++ b/ReactNativeClient/lib/models/Resource.js @@ -207,11 +207,11 @@ class Resource extends BaseItem { const lines = []; if (Resource.isSupportedImageMimeType(resource.mime)) { lines.push('!['); - lines.push(markdownUtils.escapeLinkText(tagAlt)); + lines.push(markdownUtils.escapeTitleText(tagAlt)); lines.push(`](:/${resource.id})`); } else { lines.push('['); - lines.push(markdownUtils.escapeLinkText(tagAlt)); + lines.push(markdownUtils.escapeTitleText(tagAlt)); lines.push(`](:/${resource.id})`); } return lines.join(''); diff --git a/ReactNativeClient/lib/shim-init-node.js b/ReactNativeClient/lib/shim-init-node.js index 28c8f02cb..fe571aac6 100644 --- a/ReactNativeClient/lib/shim-init-node.js +++ b/ReactNativeClient/lib/shim-init-node.js @@ -211,7 +211,7 @@ function shimInit() { }, options); const { basename } = require('path'); - const { escapeLinkText } = require('lib/markdownUtils'); + const { escapeTitleText } = require('lib/markdownUtils'); const { toFileProtocolPath } = require('lib/path-utils'); let resource = null; @@ -231,7 +231,7 @@ function shimInit() { if (!options.createFileURL) { newBody.push(Resource.markdownTag(resource)); } else { - const filename = escapeLinkText(basename(filePath)); // to get same filename as standard drag and drop + const filename = escapeTitleText(basename(filePath)); // to get same filename as standard drag and drop const fileURL = `[${filename}](${toFileProtocolPath(filePath)})`; newBody.push(fileURL); }