From a90781dcf5ff50f763f62bdebbaf61367d7bb5d5 Mon Sep 17 00:00:00 2001 From: Rickard Falk Date: Wed, 30 Aug 2023 14:07:56 +0200 Subject: [PATCH] fix: csp violation for style attributes https://github.com/klaro-org/klaro-js/issues/480 --- src/consent-manager.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/consent-manager.js b/src/consent-manager.js index 7a117fda..89def926 100644 --- a/src/consent-manager.js +++ b/src/consent-manager.js @@ -274,7 +274,12 @@ export default class ConsentManager { // place, as the script won't start correctly otherwise const newElement = document.createElement(element.tagName) for(const attribute of element.attributes){ - newElement.setAttribute(attribute.name, attribute.value) + if (attribute.name === 'style') { + const [styleProperty, styleValue] = attribute.value.split(':') + newElement.style[styleProperty.trim()] = styleValue.trim() + } else { + newElement.setAttribute(attribute.name, attribute.value) + } } newElement.innerText = element.innerText newElement.text = element.text