You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-24 23:26:50 +02:00
Desktop: Fixes #5034: Certain resource paths could be corrupted when saved from the Rich Text editor
This commit is contained in:
@ -284,8 +284,20 @@ describe('models_Note', function() {
|
|||||||
expect(externalToInternal).toBe(input);
|
expect(externalToInternal).toBe(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await Note.replaceResourceExternalToInternalLinks(`[](joplin://${note1.id})`);
|
{
|
||||||
expect(result).toBe(`[](:/${note1.id})`);
|
const result = await Note.replaceResourceExternalToInternalLinks(`[](joplin://${note1.id})`);
|
||||||
|
expect(result).toBe(`[](:/${note1.id})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// This is a regular file path that contains the resourceDirName
|
||||||
|
// inside but it shouldn't be changed.
|
||||||
|
//
|
||||||
|
// https://github.com/laurent22/joplin/issues/5034
|
||||||
|
const noChangeInput = `[docs](file:///c:/foo/${resourceDirName}/docs)`;
|
||||||
|
const result = await Note.replaceResourceExternalToInternalLinks(noChangeInput, { useAbsolutePaths: false });
|
||||||
|
expect(result).toBe(noChangeInput);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should perform natural sorting', (async () => {
|
it('should perform natural sorting', (async () => {
|
||||||
|
@ -208,9 +208,9 @@ export default class Note extends BaseItem {
|
|||||||
for (const basePath of pathsToTry) {
|
for (const basePath of pathsToTry) {
|
||||||
const reStrings = [
|
const reStrings = [
|
||||||
// Handles file://path/to/abcdefg.jpg?t=12345678
|
// Handles file://path/to/abcdefg.jpg?t=12345678
|
||||||
`${pregQuote(`${basePath}/`)}[a-zA-Z0-9.]+\\?t=[0-9]+`,
|
`${pregQuote(`${basePath}/`)}[a-zA-Z0-9]{32}\\.[a-zA-Z0-9]+\\?t=[0-9]+`,
|
||||||
// Handles file://path/to/abcdefg.jpg
|
// Handles file://path/to/abcdefg.jpg
|
||||||
`${pregQuote(`${basePath}/`)}[a-zA-Z0-9.]+`,
|
`${pregQuote(`${basePath}/`)}[a-zA-Z0-9]{32}\\.[a-zA-Z0-9]+`,
|
||||||
];
|
];
|
||||||
for (const reString of reStrings) {
|
for (const reString of reStrings) {
|
||||||
const re = new RegExp(reString, 'gi');
|
const re = new RegExp(reString, 'gi');
|
||||||
|
Reference in New Issue
Block a user