diff --git a/CliClient/tests/MdToMd.js b/CliClient/tests/MdToMd.js index 186b7f40c4..d10278d661 100644 --- a/CliClient/tests/MdToMd.js +++ b/CliClient/tests/MdToMd.js @@ -38,4 +38,9 @@ describe('InteropService_Importer_Md: importLocalImages', function() { expect(items.length).toBe(0); expect(note.body).toContain('Unidentified vessel travelling at sub warp speed, bearing 235.7. Fluctuations in energy readings from it, Captain. All transporters off.'); }); + it('should import linked image with special characters in name', async function() { + const note = await importer.importFile(`${__dirname}/md_to_md/sample-special-chars.md`, 'notebook'); + const items = await Note.linkedItems(note.body); + expect(items.length).toBe(1); + }); }); diff --git a/CliClient/tests/md_to_md/sample-special-chars.md b/CliClient/tests/md_to_md/sample-special-chars.md new file mode 100644 index 0000000000..3bc1a5ed07 --- /dev/null +++ b/CliClient/tests/md_to_md/sample-special-chars.md @@ -0,0 +1 @@ +![link special chars](../support/photo-åäö.jpg) diff --git a/CliClient/tests/support/photo-åäö.jpg b/CliClient/tests/support/photo-åäö.jpg new file mode 100644 index 0000000000..b258679de6 Binary files /dev/null and b/CliClient/tests/support/photo-åäö.jpg differ diff --git a/CliClient/tests/support/photo-åäö.jpg b/CliClient/tests/support/photo-åäö.jpg new file mode 100644 index 0000000000..b258679de6 Binary files /dev/null and b/CliClient/tests/support/photo-åäö.jpg differ diff --git a/ReactNativeClient/lib/services/InteropService_Importer_Md.js b/ReactNativeClient/lib/services/InteropService_Importer_Md.js index 2cb99ca066..d4e029c463 100644 --- a/ReactNativeClient/lib/services/InteropService_Importer_Md.js +++ b/ReactNativeClient/lib/services/InteropService_Importer_Md.js @@ -63,7 +63,8 @@ class InteropService_Importer_Md extends InteropService_Importer_Base { async importLocalImages(filePath, md) { let updated = md; const imageLinks = unique(extractImageUrls(md)); - await Promise.all(imageLinks.map(async (link) => { + await Promise.all(imageLinks.map(async (encodedLink) => { + const link = decodeURI(encodedLink); const attachmentPath = filename(`${dirname(filePath)}/${link}`, true); const pathWithExtension = `${attachmentPath}.${fileExtension(link)}`; const stat = await shim.fsDriver().stat(pathWithExtension);