From 18d1735c01bbfec8706f89fc7a2a996be7eee7a8 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 19 Apr 2019 05:59:50 +0200 Subject: [PATCH] editor: don't eat backslashes in enquoted strings (#515) --- CHANGELOG.md | 1 + src/client/app/editor/edit-field.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b559e830..94e1b174 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - bug fixes - bottom horizontal scrollbar not responding on small screens - remote file browser: hitting a letter to select a file based on its name was looping on the first two matches only + - editor: preserve backslashes in enquoted strings (not in objects/arrays) - widgets - `logScale` can be set to a number to use a logarithm base different from the default - knob: `compact` mode is back diff --git a/src/client/app/editor/edit-field.js b/src/client/app/editor/edit-field.js index bf9f0f7c..4f458fd0 100644 --- a/src/client/app/editor/edit-field.js +++ b/src/client/app/editor/edit-field.js @@ -103,6 +103,11 @@ module.exports = function editField(editor, widget, propName, defaultValue){ try { v = JSON.parseFlex(input.value) + if (typeof v === 'string') { + // escape backslashes in simple strings only + v = JSON.parseFlex(input.value.replace(/\\/g, '__BACKSLASH__')) + v = v.replace(/__BACKSLASH__/g, '\\') + } } catch(err) { v = input.value }