Skip to content

Commit

Permalink
Handle unicode in webview events.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdomhan committed Dec 18, 2024
1 parent c2952a7 commit 8ac3fc5
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/desktop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async-trait = "0.1.68"
tao = { workspace = true, features = ["rwh_05"] }
once_cell = { workspace = true }
dioxus-history.workspace = true
base64.workspace = true


[target.'cfg(unix)'.dependencies]
Expand Down
12 changes: 9 additions & 3 deletions packages/desktop/src/webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
waker::tao_waker,
Config, DesktopContext, DesktopService,
};
use base64::prelude::BASE64_STANDARD;
use dioxus_core::{Runtime, ScopeId, VirtualDom};
use dioxus_document::Document;
use dioxus_history::{History, MemoryHistory};
Expand Down Expand Up @@ -59,10 +60,15 @@ impl WebviewEdits {
let data_from_header = request
.headers()
.get("dioxus-data")
.map(|f| f.as_bytes())
.expect("dioxus-data header is not a string");
.map(|f| {
std::str::from_utf8(f.as_bytes())
.expect("dioxus-data header is not a valid (utf-8) string")
})
.expect("dioxus-data header not set");
let data_from_header = base64::Engine::decode(&BASE64_STANDARD, data_from_header)
.expect("dioxus-data header is not a base64 string");

let response = match serde_json::from_slice(data_from_header) {
let response = match serde_json::from_slice(&data_from_header) {
Ok(event) => {
// we need to wait for the mutex lock to let us munge the main thread..
let _lock = crate::android_sync_lock::android_runtime_lock();
Expand Down
2 changes: 1 addition & 1 deletion packages/interpreter/src/js/common.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/interpreter/src/js/core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/interpreter/src/js/hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[6449103750905854967, 3846442265490457921, 13069001215487072322, 8716623267269178440, 5336385715226370016, 14456089431355876478, 12156139214887111728, 5052021921702764563, 12925655762638175824, 5638004933879392817]
[22183138833260907, 6449103750905854967, 3940453019586793214, 3846442265490457921, 13478645935057287689, 13069001215487072322, 9804649440181677258, 8716623267269178440, 7790983660500237797, 5336385715226370016, 12929160883278153301, 14456089431355876478, 3587738331530929625, 17849315463685614672, 7823221600277385649, 5052021921702764563, 5026625984394339997, 12925655762638175824, 5957263916133708360, 5638004933879392817]
2 changes: 1 addition & 1 deletion packages/interpreter/src/js/hydrate.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/interpreter/src/js/initialize_streaming.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8ac3fc5

Please sign in to comment.