补齐桌面壳图片导出空字节边界
桌面壳图片导出解码后拒绝空字节内容 桌面壳 Rust 测试覆盖图片导出空内容拒绝 桌面壳配置检查反查图片导出字节边界
This commit is contained in:
@@ -2294,6 +2294,17 @@ assertSameList(
|
||||
requiredRustHostModules,
|
||||
'desktop shell Rust bridge modules',
|
||||
);
|
||||
const desktopExportImagePayloadBody = extractFunctionBody(
|
||||
desktopHostBridgeFilesSource,
|
||||
'export_image_payload',
|
||||
);
|
||||
if (
|
||||
!desktopExportImagePayloadBody.includes(
|
||||
'bytes.is_empty() || bytes.len() > EXPORT_IMAGE_MAX_BYTES',
|
||||
)
|
||||
) {
|
||||
throw new Error('desktop shell image export must reject empty and oversized bytes');
|
||||
}
|
||||
assertSameList(
|
||||
extractNativeAppTauriInvokeCommands(nativeAppHostBridgeSource),
|
||||
['HOST_BRIDGE_TAURI_COMMAND'],
|
||||
|
||||
@@ -392,7 +392,7 @@ pub(crate) fn export_image_payload(
|
||||
"base64Data is invalid",
|
||||
)
|
||||
})?;
|
||||
if bytes.len() > EXPORT_IMAGE_MAX_BYTES {
|
||||
if bytes.is_empty() || bytes.len() > EXPORT_IMAGE_MAX_BYTES {
|
||||
return Err(failed(
|
||||
request.id.clone(),
|
||||
"invalid_request",
|
||||
@@ -1272,6 +1272,15 @@ mod tests {
|
||||
"base64Data is invalid"
|
||||
);
|
||||
|
||||
let mut empty = request("file.exportImage");
|
||||
empty.payload = Some(json!({
|
||||
"fileName": "分享卡.png",
|
||||
"base64Data": "",
|
||||
"mimeType": "image/png"
|
||||
}));
|
||||
let response = export_image_payload(&empty).expect_err("empty image");
|
||||
assert_eq!(response.error.expect("error").code, "invalid_request");
|
||||
|
||||
let mut mismatched = request("file.exportImage");
|
||||
mismatched.payload = Some(json!({
|
||||
"fileName": "分享卡.png",
|
||||
|
||||
Reference in New Issue
Block a user