From b0b935ddffc36601ee4fb93f39db89c695236c36 Mon Sep 17 00:00:00 2001 From: tvongaza Date: Wed, 8 May 2024 16:32:59 -0600 Subject: [PATCH 1/2] Read the csp meta tag nonce attribute and fall back to content --- src/trix/core/helpers/custom_elements.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/trix/core/helpers/custom_elements.js b/src/trix/core/helpers/custom_elements.js index 5273fe63b..6cf107853 100644 --- a/src/trix/core/helpers/custom_elements.js +++ b/src/trix/core/helpers/custom_elements.js @@ -17,10 +17,11 @@ const insertStyleElementForTagName = function(tagName) { return element } -const getCSPNonce = function() { +const getCSPNonce = function () { const element = getMetaElement("trix-csp-nonce") || getMetaElement("csp-nonce") if (element) { - return element.getAttribute("content") + const { nonce, content } = element + return nonce == "" ? content : nonce } } From eb1539c1eca265210d774352bb10765d48408396 Mon Sep 17 00:00:00 2001 From: Tys von Gaza Date: Wed, 8 May 2024 16:35:15 -0600 Subject: [PATCH 2/2] Update custom_elements.js Fix whitespace --- src/trix/core/helpers/custom_elements.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trix/core/helpers/custom_elements.js b/src/trix/core/helpers/custom_elements.js index 6cf107853..1e0fc5734 100644 --- a/src/trix/core/helpers/custom_elements.js +++ b/src/trix/core/helpers/custom_elements.js @@ -17,7 +17,7 @@ const insertStyleElementForTagName = function(tagName) { return element } -const getCSPNonce = function () { +const getCSPNonce = function() { const element = getMetaElement("trix-csp-nonce") || getMetaElement("csp-nonce") if (element) { const { nonce, content } = element