Skip to content

Commit 0503eb6

Browse files
fix(core): account for data: uri when calculating origin, closes #7078 (#7133)
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
1 parent 85e77fb commit 0503eb6

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri': 'patch:bug'
3+
---
4+
5+
On macOS and Linux, fix app crashing when creating a window with `data:` uri.

core/tauri/src/manager.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -471,21 +471,21 @@ impl<R: Runtime> WindowManager<R> {
471471
}
472472

473473
let window_url = Url::parse(&pending.url).unwrap();
474-
let window_origin =
475-
if cfg!(windows) && window_url.scheme() != "http" && window_url.scheme() != "https" {
476-
format!("https://{}.localhost", window_url.scheme())
477-
} else {
478-
format!(
479-
"{}://{}{}",
480-
window_url.scheme(),
481-
window_url.host().unwrap(),
482-
if let Some(port) = window_url.port() {
483-
format!(":{port}")
484-
} else {
485-
"".into()
486-
}
487-
)
488-
};
474+
let window_origin = if window_url.scheme() == "data" {
475+
"null".into()
476+
} else if cfg!(windows) && window_url.scheme() != "http" && window_url.scheme() != "https" {
477+
format!("https://{}.localhost", window_url.scheme())
478+
} else {
479+
format!(
480+
"{}://{}{}",
481+
window_url.scheme(),
482+
window_url.host().unwrap(),
483+
window_url
484+
.port()
485+
.map(|p| format!(":{p}"))
486+
.unwrap_or_default()
487+
)
488+
};
489489

490490
if !registered_scheme_protocols.contains(&"tauri".into()) {
491491
let web_resource_request_handler = pending.web_resource_request_handler.take();

0 commit comments

Comments
 (0)