1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Fixes #2334: MD importer handle special chars in linked image name (#2346)

* md importer: decode uri encoded links to cover case of special chars in linked image names

* md importer: temp debug logs for linux test pipeline

* md importer: more temp debug logs

* md importer: tests, add special char image name on linux

* md importer: tests, use const not let

* md importer: remove debug logs
This commit is contained in:
Bart 2020-03-27 12:20:38 +00:00 committed by GitHub
parent ae73051797
commit 37158fdb89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 1 deletions

View File

@ -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);
});
});

View File

@ -0,0 +1 @@
![link special chars](../support/photo-åäö.jpg)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -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);