Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable nonce creation by default #942

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Trunk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ minify = "never" # can be one of: never, on_release, always
no_sri = false
# An optional cargo profile to use
# cargo_profile = "release-trunk"
# Allow injecting a nonce attribute
create_nonce = false

[watch]
# Paths to watch. The `build.target`'s parent folder is watched by default.
Expand Down
4 changes: 2 additions & 2 deletions schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"all_features": false,
"allow_self_closing_script": false,
"cargo_profile": null,
"create_nonce": true,
"create_nonce": false,
"dist": "dist",
"filehash": true,
"frozen": false,
Expand Down Expand Up @@ -120,7 +120,7 @@
},
"create_nonce": {
"description": "Create 'nonce' attributes with a placeholder.",
"default": true,
"default": false,
"type": "boolean"
},
"dist": {
Expand Down
8 changes: 2 additions & 6 deletions src/config/models/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub struct Build {
pub allow_self_closing_script: bool,

/// Create 'nonce' attributes with a placeholder.
#[serde(default = "default::create_nonce")]
#[serde(default)]
pub create_nonce: bool,

/// The placeholder which is used in the 'nonce' attribute.
Expand Down Expand Up @@ -230,7 +230,7 @@ impl Default for Build {
minify: Default::default(),
no_sri: false,
allow_self_closing_script: false,
create_nonce: true,
create_nonce: false,
nonce_placeholder: default::nonce_placeholder(),
}
}
Expand All @@ -256,10 +256,6 @@ mod default {
true
}

pub const fn create_nonce() -> bool {
true
}

pub fn nonce_placeholder() -> String {
"{{__TRUNK NONCE__}}".to_string()
}
Expand Down