1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-09-05 20:56:22 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Laurent Cozic
6670f9ae1c Desktop release v2.13.11 2023-12-24 11:26:28 +00:00
Laurent Cozic
09506a7b40 Desktop, Cli: Fixes #9548: Import ENEX archives that contain files with invalid names 2023-12-24 11:26:07 +00:00
6 changed files with 50 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "@joplin/app-desktop",
"version": "2.13.10",
"version": "2.13.11",
"description": "Joplin for Desktop",
"main": "main.js",
"private": true,

Submodule packages/default-plugins/plugin-sources/io.github.jackgruber.backup added at 021085cc37

View File

@@ -204,4 +204,12 @@ describe('import-enex-md-gen', () => {
expect(resource.title).toBe('app_images/resizable/961b875f-24ac-402f-9b76-37e2d4f03a6c/house_500.jpg.png');
});
it('should sanitize resource filenames with colons', async () => {
await importEnexFile('resource_filename_with_colons.enex');
const resource: ResourceEntity = (await Resource.all())[0];
expect(resource.filename).toBe('08.06.2014165855');
expect(resource.file_extension).toBe('2014165855');
expect(resource.title).toBe('08.06.2014 16:58:55');
});
});

View File

@@ -9,7 +9,7 @@ import shim from './shim';
import { NoteEntity, ResourceEntity } from './services/database/types';
import { enexXmlToMd } from './import-enex-md-gen';
import { MarkupToHtml } from '@joplin/renderer';
import { fileExtension, friendlySafeFilename } from './path-utils';
import { fileExtension, friendlySafeFilename, safeFileExtension } from './path-utils';
const moment = require('moment');
const { wrapError } = require('./errorUtils');
const { enexXmlToHtml } = require('./import-enex-html-gen.js');
@@ -208,7 +208,7 @@ async function saveNoteResources(note: ExtractedNote) {
delete (toSave as any).dataFilePath;
delete (toSave as any).dataEncoding;
delete (toSave as any).hasData;
toSave.file_extension = resource.filename ? fileExtension(resource.filename) : '';
toSave.file_extension = resource.filename ? safeFileExtension(fileExtension(resource.filename)) : '';
// ENEX resource filenames can contain slashes, which may confuse other
// parts of the app, which expect this `filename` field to be safe.

View File

@@ -39,6 +39,9 @@ export function isHidden(path: string) {
return b[0] === '.';
}
// Note that this function only sanitizes a file extension - it does NOT extract
// the file extension from a filename. So the way you'd normally call this is
// `safeFileExtension(fileExtension(filename))`
export function safeFileExtension(e: string, maxLength: number = null) {
// In theory the file extension can have any length but in practice Joplin
// expects a fixed length, so we limit it to 20 which should cover most cases.