From 51e40ddbc9427144ab574fe8d3cc3403e7d49030 Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 13 Apr 2020 18:16:33 +0000 Subject: [PATCH] ace2_inner: when atext.text is "", replace with "\n" The server is fine with atext.text being an empty string, but the front end is not, and crashes. It is not clear if this is a problem in the server or in the client code, and this is a client-side hack fix. The underlying problem needs to be investigated. See for reference: - https://github.com/ether/etherpad-lite/issues/3861 --- src/static/js/ace2_inner.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index be7376978..aaecae1e6 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -737,6 +737,22 @@ function Ace2Inner(){ function setDocAText(atext) { + if (atext.text === "") { + /* + * The server is fine with atext.text being an empty string, but the front + * end is not, and crashes. + * + * It is not clear if this is a problem in the server or in the client + * code, and this is a client-side hack fix. The underlying problem needs + * to be investigated. + * + * See for reference: + * - https://github.com/ether/etherpad-lite/issues/3861 + */ + console.warn('atext.text is an empty string(""). Replacing with "\\n". See issue #3861.'); + atext.text = "\n"; + } + fastIncorp(8); var oldLen = rep.lines.totalWidth();