From c57e098d662bc70a8f3eed3c3aa52f13e54ab1f3 Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 10 Oct 2025 15:51:11 +0800 Subject: [PATCH 1/2] fix: skip empty script tag for CSP hash properly --- crates/tauri-codegen/src/context.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tauri-codegen/src/context.rs b/crates/tauri-codegen/src/context.rs index ed61481d2a9a..9176aea64849 100644 --- a/crates/tauri-codegen/src/context.rs +++ b/crates/tauri-codegen/src/context.rs @@ -45,7 +45,7 @@ pub struct ContextData { } fn inject_script_hashes(document: &NodeRef, key: &AssetKey, csp_hashes: &mut CspHashes) { - if let Ok(inline_script_elements) = document.select("script:not(empty)") { + if let Ok(inline_script_elements) = document.select("script:not(:empty)") { let mut scripts = Vec::new(); for inline_script_el in inline_script_elements { let script = inline_script_el.as_node().text_contents(); From 4f7976559db2d7d454c5c2366c01bad1f344c66d Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Fri, 10 Oct 2025 07:40:09 -0300 Subject: [PATCH 2/2] add change file --- .changes/fix-csp-empty-selector.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/fix-csp-empty-selector.md diff --git a/.changes/fix-csp-empty-selector.md b/.changes/fix-csp-empty-selector.md new file mode 100644 index 000000000000..e40457b1ea61 --- /dev/null +++ b/.changes/fix-csp-empty-selector.md @@ -0,0 +1,5 @@ +--- +"tauri-codegen": patch:bug +--- + +Do not hash empty scripts when generating the Content-Security-Policy SHA-256 hashes.