Skip to content

Commit c5008b8

Browse files
fix: skip empty script tag for CSP hash properly (#14274)
* fix: skip empty script tag for CSP hash properly * add change file --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app>
1 parent b5aa018 commit c5008b8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changes/fix-csp-empty-selector.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-codegen": patch:bug
3+
---
4+
5+
Do not hash empty scripts when generating the Content-Security-Policy SHA-256 hashes.

crates/tauri-codegen/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub struct ContextData {
4545
}
4646

4747
fn inject_script_hashes(document: &NodeRef, key: &AssetKey, csp_hashes: &mut CspHashes) {
48-
if let Ok(inline_script_elements) = document.select("script:not(empty)") {
48+
if let Ok(inline_script_elements) = document.select("script:not(:empty)") {
4949
let mut scripts = Vec::new();
5050
for inline_script_el in inline_script_elements {
5151
let script = inline_script_el.as_node().text_contents();

0 commit comments

Comments
 (0)