mirror of
https://github.com/laurent22/joplin.git
synced 2025-02-07 19:30:04 +02:00
parent
d817ddd5c6
commit
83db585c0b
@ -0,0 +1 @@
|
||||
![malformed link](https://malformed_uri/%E0%A4%A.jpg)
|
@ -195,4 +195,13 @@ describe('InteropService_Importer_Md', () => {
|
||||
// The invalid image is imported as-is
|
||||
expect(resource.title).toBe('invalid-image.jpg');
|
||||
});
|
||||
|
||||
it('should not fail to import file that contains a malformed URI', async () => {
|
||||
// The first implicit test is that the below call doesn't throw due to the malformed URI
|
||||
const note = await importNote(`${supportDir}/test_notes/md/sample-malformed-uri.md`);
|
||||
const itemIds = Note.linkedItemIds(note.body);
|
||||
expect(itemIds.length).toBe(0);
|
||||
// The malformed link is imported as-is
|
||||
expect(note.body).toContain('![malformed link](https://malformed_uri/%E0%A4%A.jpg)');
|
||||
});
|
||||
});
|
||||
|
@ -110,11 +110,18 @@ export default class InteropService_Importer_Md extends InteropService_Importer_
|
||||
const htmlLinks = htmlUtils.extractFileUrls(md);
|
||||
const fileLinks = unique(markdownLinks.concat(htmlLinks));
|
||||
for (const encodedLink of fileLinks) {
|
||||
const link = decodeURI(encodedLink);
|
||||
let link = '';
|
||||
try {
|
||||
link = decodeURI(encodedLink);
|
||||
} catch (error) {
|
||||
// If the URI cannot be decoded, leave it as it is.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isDataUrl(link)) {
|
||||
// Just leave it as it is. We could potentially import
|
||||
// it as a resource but for now that's good enough.
|
||||
continue;
|
||||
} else {
|
||||
// Handle anchor links appropriately
|
||||
const trimmedLink = this.trimAnchorLink(link);
|
||||
|
Loading…
x
Reference in New Issue
Block a user