From d6de56b2db64e63ccec3e2e5ae3890a7a9efd1a1 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Wed, 31 Jan 2018 19:01:11 +0000 Subject: [PATCH] All: Fixed crash when having invalid UTF-8 string in text editor --- CliClient/app/command-sync.js | 2 +- ReactNativeClient/lib/MdToHtml.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CliClient/app/command-sync.js b/CliClient/app/command-sync.js index 5e2d52f4b..99db6ed9b 100644 --- a/CliClient/app/command-sync.js +++ b/CliClient/app/command-sync.js @@ -101,7 +101,7 @@ class Command extends BaseCommand { this.releaseLockFn_ = null; // Lock is unique per profile/database - const lockFilePath = osTmpdir() + '/synclock_' + md5(Setting.value('profileDir')); + const lockFilePath = osTmpdir() + '/synclock_' + md5(escape(Setting.value('profileDir'))); // https://github.com/pvorb/node-md5/issues/41 if (!await fs.pathExists(lockFilePath)) await fs.writeFile(lockFilePath, 'synclock'); try { diff --git a/ReactNativeClient/lib/MdToHtml.js b/ReactNativeClient/lib/MdToHtml.js index 7510e0747..ccb6cc317 100644 --- a/ReactNativeClient/lib/MdToHtml.js +++ b/ReactNativeClient/lib/MdToHtml.js @@ -28,7 +28,7 @@ class MdToHtml { const r = resources[n]; k.push(r.id); } - k.push(md5(body)); + k.push(md5(escape(body))); // https://github.com/pvorb/node-md5/issues/41 k.push(md5(JSON.stringify(style))); k.push(md5(JSON.stringify(options))); return k.join('_');