1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

All: Fix handling of new line escaping when using external edit

This commit is contained in:
Laurent Cozic
2020-11-23 16:25:57 +00:00
parent 86bace70a5
commit 1dd6c7dde5
2 changed files with 34 additions and 3 deletions

View File

@@ -260,7 +260,13 @@ class BaseItem extends BaseModel {
propValue = `${propValue}`;
}
return propValue.replace(/\n/g, '\\n').replace(/\r/g, '\\r');
if (propName === 'body') return propValue;
return propValue
.replace(/\\n/g, '\\\\n')
.replace(/\\r/g, '\\\\r')
.replace(/\n/g, '\\n')
.replace(/\r/g, '\\r');
}
static unserialize_format(type, propName, propValue) {
@@ -281,7 +287,14 @@ class BaseItem extends BaseModel {
propValue = Database.formatValue(ItemClass.fieldType(propName), propValue);
}
return typeof propValue === 'string' ? propValue.replace(/\\n/g, '\n').replace(/\\r/g, '\r') : propValue;
if (propName === 'body') return propValue;
return typeof propValue === 'string' ? propValue
.replace(/\\n/g, '\n')
.replace(/\\r/g, '\r')
.replace(/\\\n/g, '\\n')
.replace(/\\\r/g, '\\r')
: propValue;
}
static async serialize(item, shownKeys = null) {