Skip to content

Commit 3a4c016

Browse files
authored
fix(core): change default freezePrototype to false, closes #3416 #3406 (#3423)
1 parent c010360 commit 3a4c016

5 files changed

Lines changed: 15 additions & 22 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri": patch
3+
"tauri-utils": patch
4+
---
5+
6+
Change default value for the `freezePrototype` configuration to `false`.

core/tauri-codegen/src/embedded_assets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl AssetOptions {
192192
Self {
193193
csp: false,
194194
pattern,
195-
freeze_prototype: true,
195+
freeze_prototype: false,
196196
#[cfg(feature = "isolation")]
197197
isolation_schema: format!("isolation-{}", uuid::Uuid::new_v4()),
198198
}

core/tauri-utils/src/config.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ fn default_file_drop_enabled() -> bool {
573573

574574
/// Security configuration.
575575
#[skip_serializing_none]
576-
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
576+
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)]
577577
#[cfg_attr(feature = "schema", derive(JsonSchema))]
578578
#[serde(rename_all = "camelCase", deny_unknown_fields)]
579579
pub struct SecurityConfig {
@@ -589,24 +589,10 @@ pub struct SecurityConfig {
589589
/// See <https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP>.
590590
pub dev_csp: Option<String>,
591591
/// Freeze the `Object.prototype` when using the custom protocol.
592-
#[serde(default = "default_freeze_prototype")]
592+
#[serde(default)]
593593
pub freeze_prototype: bool,
594594
}
595595

596-
impl Default for SecurityConfig {
597-
fn default() -> Self {
598-
Self {
599-
csp: None,
600-
dev_csp: None,
601-
freeze_prototype: default_freeze_prototype(),
602-
}
603-
}
604-
}
605-
606-
fn default_freeze_prototype() -> bool {
607-
true
608-
}
609-
610596
/// Defines an allowlist type.
611597
pub trait Allowlist {
612598
/// Returns all features associated with the allowlist struct.
@@ -2558,7 +2544,7 @@ mod test {
25582544
security: SecurityConfig {
25592545
csp: None,
25602546
dev_csp: None,
2561-
freeze_prototype: true,
2547+
freeze_prototype: false,
25622548
},
25632549
allowlist: AllowlistConfig::default(),
25642550
system_tray: None,

examples/api/src-tauri/tauri.conf.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@
116116
}
117117
],
118118
"security": {
119-
"csp": "default-src 'self' customprotocol: img-src: 'self'; style-src 'unsafe-inline' 'self' https://fonts.googleapis.com; img-src 'self' asset: https://asset.localhost blob: data:; font-src https://fonts.gstatic.com"
119+
"csp": "default-src 'self' customprotocol: img-src: 'self'; style-src 'unsafe-inline' 'self' https://fonts.googleapis.com; img-src 'self' asset: https://asset.localhost blob: data:; font-src https://fonts.gstatic.com",
120+
"freezePrototype": true
120121
},
121122
"systemTray": {
122123
"iconPath": "../../.icons/tray_icon_with_transparency.png",

tooling/cli/schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
"use": "brownfield"
156156
},
157157
"security": {
158-
"freezePrototype": true
158+
"freezePrototype": false
159159
},
160160
"updater": {
161161
"active": false,
@@ -1294,7 +1294,7 @@
12941294
},
12951295
"freezePrototype": {
12961296
"description": "Freeze the `Object.prototype` when using the custom protocol.",
1297-
"default": true,
1297+
"default": false,
12981298
"type": "boolean"
12991299
}
13001300
},
@@ -1609,7 +1609,7 @@
16091609
"security": {
16101610
"description": "Security configuration.",
16111611
"default": {
1612-
"freezePrototype": true
1612+
"freezePrototype": false
16131613
},
16141614
"allOf": [
16151615
{

0 commit comments

Comments
 (0)