fix(core): isolation pattern breaks raw postMessage payload (#10841)

This commit is contained in:
Lucas Fernandes Nogueira 2024-09-02 13:12:59 -03:00 committed by GitHub
parent 5048a7293b
commit 79de4332b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"tauri": patch:bug
---
Fixes IPC postMessage raw body processing when using the isolation pattern.

View File

@ -17,6 +17,7 @@ use http::{
},
HeaderValue, Method, Request, StatusCode,
};
use mime::APPLICATION_OCTET_STREAM;
use url::Url;
use super::{CallbackFn, InvokeResponse};
@ -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,
})