|
@@ -142,7 +142,10 @@ fn set_csp<R: Runtime>(
|
|
|
let default_src = csp
|
|
|
.entry("default-src".into())
|
|
|
.or_insert_with(Default::default);
|
|
|
- default_src.push(crate::pattern::format_real_schema(schema));
|
|
|
+ default_src.push(crate::pattern::format_real_schema(
|
|
|
+ schema,
|
|
|
+ manager.config().tauri.security.dangerous_use_http_scheme,
|
|
|
+ ));
|
|
|
}
|
|
|
|
|
|
Csp::DirectiveMap(csp).to_string()
|
|
@@ -388,7 +391,14 @@ impl<R: Runtime> WindowManager<R> {
|
|
|
match self.base_path() {
|
|
|
AppUrl::Url(WindowUrl::External(url)) => Cow::Borrowed(url),
|
|
|
#[cfg(windows)]
|
|
|
- _ => Cow::Owned(Url::parse("https://tauri.localhost").unwrap()),
|
|
|
+ _ => {
|
|
|
+ let scheme = if self.inner.config.tauri.security.dangerous_use_http_scheme {
|
|
|
+ "http"
|
|
|
+ } else {
|
|
|
+ "https"
|
|
|
+ };
|
|
|
+ Cow::Owned(Url::parse(&format!("{scheme}://tauri.localhost")).unwrap())
|
|
|
+ }
|
|
|
#[cfg(not(windows))]
|
|
|
_ => Cow::Owned(Url::parse("tauri://localhost").unwrap()),
|
|
|
}
|
|
@@ -429,17 +439,19 @@ impl<R: Runtime> WindowManager<R> {
|
|
|
}
|
|
|
.render_default(&Default::default())?;
|
|
|
|
|
|
+ let mut webview_attributes = pending.webview_attributes;
|
|
|
+
|
|
|
let ipc_init = IpcJavascript {
|
|
|
isolation_origin: &match self.pattern() {
|
|
|
#[cfg(feature = "isolation")]
|
|
|
- Pattern::Isolation { schema, .. } => crate::pattern::format_real_schema(schema),
|
|
|
+ Pattern::Isolation { schema, .. } => {
|
|
|
+ crate::pattern::format_real_schema(schema, pending.http_scheme)
|
|
|
+ }
|
|
|
_ => "".to_string(),
|
|
|
},
|
|
|
}
|
|
|
.render_default(&Default::default())?;
|
|
|
|
|
|
- let mut webview_attributes = pending.webview_attributes;
|
|
|
-
|
|
|
let mut window_labels = window_labels.to_vec();
|
|
|
let l = label.to_string();
|
|
|
if !window_labels.contains(&l) {
|
|
@@ -466,7 +478,7 @@ impl<R: Runtime> WindowManager<R> {
|
|
|
if let Pattern::Isolation { schema, .. } = self.pattern() {
|
|
|
webview_attributes = webview_attributes.initialization_script(
|
|
|
&IsolationJavascript {
|
|
|
- isolation_src: &crate::pattern::format_real_schema(schema),
|
|
|
+ isolation_src: &crate::pattern::format_real_schema(schema, pending.http_scheme),
|
|
|
style: tauri_utils::pattern::isolation::IFRAME_STYLE,
|
|
|
}
|
|
|
.render_default(&Default::default())?
|
|
@@ -491,7 +503,8 @@ impl<R: Runtime> WindowManager<R> {
|
|
|
let window_origin = if window_url.scheme() == "data" {
|
|
|
"null".into()
|
|
|
} else if cfg!(windows) && window_url.scheme() != "http" && window_url.scheme() != "https" {
|
|
|
- format!("https://{}.localhost", window_url.scheme())
|
|
|
+ let scheme = if pending.http_scheme { "http" } else { "https" };
|
|
|
+ format!("{scheme}://{}.localhost", window_url.scheme())
|
|
|
} else {
|
|
|
format!(
|
|
|
"{}://{}{}",
|
|
@@ -782,6 +795,13 @@ impl<R: Runtime> WindowManager<R> {
|
|
|
hotkeys: &'a str,
|
|
|
}
|
|
|
|
|
|
+ #[derive(Template)]
|
|
|
+ #[default_template("../scripts/core.js")]
|
|
|
+ struct CoreJavascript<'a> {
|
|
|
+ os_name: &'a str,
|
|
|
+ protocol_scheme: &'a str,
|
|
|
+ }
|
|
|
+
|
|
|
let bundle_script = if with_global_tauri {
|
|
|
include_str!("../scripts/bundle.global.js")
|
|
|
} else {
|
|
@@ -813,7 +833,16 @@ impl<R: Runtime> WindowManager<R> {
|
|
|
"window['_' + window.__TAURI__.transformCallback(cb) ]".into()
|
|
|
)
|
|
|
),
|
|
|
- core_script: include_str!("../scripts/core.js"),
|
|
|
+ core_script: &CoreJavascript {
|
|
|
+ os_name: std::env::consts::OS,
|
|
|
+ protocol_scheme: if self.inner.config.tauri.security.dangerous_use_http_scheme {
|
|
|
+ "http"
|
|
|
+ } else {
|
|
|
+ "https"
|
|
|
+ },
|
|
|
+ }
|
|
|
+ .render_default(&Default::default())?
|
|
|
+ .into_string(),
|
|
|
event_initialization_script: &self.event_initialization_script(),
|
|
|
plugin_initialization_script,
|
|
|
freeze_prototype,
|