From a1c14528bb8eb4078be8f1469debbdd8cad00db4 Mon Sep 17 00:00:00 2001 From: georgel-pop-lr Date: Mon, 18 May 2020 13:38:57 +0200 Subject: [PATCH] Fixes #1393 If data-style attribute is not a valid JSON a exception will be thrown and the code will stop working --- src/plugins/embedurl.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/embedurl.js b/src/plugins/embedurl.js index ee68d5a7a2..ef44f82ce2 100644 --- a/src/plugins/embedurl.js +++ b/src/plugins/embedurl.js @@ -406,11 +406,19 @@ if (!CKEDITOR.plugins.get('embedurl')) { // Sync dimensions and alignment with editor wrapper + let styles = null; + const stylesJSON = instance.element.getAttribute( 'data-styles' ); - let styles = stylesJSON ? JSON.parse(stylesJSON) : null; + if (stylesJSON) { + try { + styles = JSON.parse(stylesJSON); + } catch (e) { + console.warn('Unable to parse data-styles attribute!'); + } + } if (!styles) { const iframe = instance.wrapper.findOne('iframe');