From 954d7a6b4ab8a706dfc9361a3424cd34da593f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Tue, 24 Oct 2023 09:36:42 +0000 Subject: [PATCH] [FIX] im_livechat: no crash in safari with livechat chatbot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, when using a livechat chatbot from visitor and selecting a chatbot option, there was the following traceback: ``` UncaughtPromiseError > SyntaxError Uncaught Promise > JSON Parse error: Unterminated string SyntaxError: JSON Parse error: Unterminated string parse@[native code] updateSession ``` This happens because the session cookie had incorrect format for its content. This was caused by a history prop whose content had the character "→". When setting the cookie, the stringified object is only partially inserted until this "→", which made the content non-JSON parseable as the string is incomplete. This commit fixes the issue by replacing all occurrences of the character "→" by a whitespace, so that the setting of the cookie works and insert the whole stringified object as intended. Note that this "→" is used for data that is not used in the context of livechat chatbot for the visitor, therefore this alteration of the content has functionally no effect. opw-3527969 closes odoo/odoo#139606 X-original-commit: 64efe60f92679767af769125ce7515ca3fff8c49 Signed-off-by: Matthieu Stockbauer (tsm) Signed-off-by: Alexandre Kühn (aku) --- addons/im_livechat/static/src/embed/common/livechat_service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/im_livechat/static/src/embed/common/livechat_service.js b/addons/im_livechat/static/src/embed/common/livechat_service.js index 8f9d4ae0f98..4f72d325ff3 100644 --- a/addons/im_livechat/static/src/embed/common/livechat_service.js +++ b/addons/im_livechat/static/src/embed/common/livechat_service.js @@ -116,7 +116,7 @@ export class LivechatService { }); cookie.delete(this.SESSION_COOKIE); cookie.delete(this.OPERATOR_COOKIE); - cookie.set(this.SESSION_COOKIE, JSON.stringify(session), 60 * 60 * 24); // 1 day cookie. + cookie.set(this.SESSION_COOKIE, JSON.stringify(session).replaceAll("→", " "), 60 * 60 * 24); // 1 day cookie. if (session?.operator_pid) { cookie.set(this.OPERATOR_COOKIE, session.operator_pid[0], 7 * 24 * 60 * 60); // 1 week cookie. }