Skip to content

Commit

Permalink
fix(core): isolation pattern breaks raw postMessage payload (#10841)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Sep 2, 2024
1 parent 5048a72 commit 79de433
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/fix-isolation-parse-raw-body.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch:bug
---

Fixes IPC postMessage raw body processing when using the isolation pattern.
9 changes: 8 additions & 1 deletion crates/tauri/src/ipc/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use http::{
},
HeaderValue, Method, Request, StatusCode,
};
use mime::APPLICATION_OCTET_STREAM;
use url::Url;

use super::{CallbackFn, InvokeResponse};
Expand Down Expand Up @@ -278,11 +279,17 @@ fn handle_ipc_message<R: Runtime>(request: Request<String>, manager: &AppManager
serde_json::from_str::<IsolationMessage<'_>>(request.body())
.map_err(Into::into)
.and_then(|message| {
let is_raw = message.payload.content_type() == &APPLICATION_OCTET_STREAM.to_string();
let payload = crypto_keys.decrypt(message.payload)?;
Ok(Message {
cmd: message.cmd,
callback: message.callback,
error: message.error,
payload: serde_json::from_slice(&crypto_keys.decrypt(message.payload)?)?,
payload: if is_raw {
payload.into()
} else {
serde_json::from_slice(&payload)?
},
options: message.options,
invoke_key: message.invoke_key,
})
Expand Down

0 comments on commit 79de433

Please sign in to comment.