fix: mail-parser-wasm missing message/rfc822 attachments (#897)

* fix: mail-parser-wasm treat message/rfc822 attachments as regular attachments

Previously, message/rfc822 attachments (e.g. .eml files) were
recursively parsed for sub-attachments instead of being returned
directly, causing them to be silently dropped. Now all attachments
are returned regardless of type.

Bump version to 0.2.2. Add .gitignore for worker build artifacts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: add missing entries to worker .gitignore

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: bump mail-parser-wasm to 0.2.2 in frontend

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dream Hunter
2026-03-14 02:52:13 +08:00
committed by GitHub
co-authored by Claude Opus 4.6
parent e7df77cac0
commit e35c246757
6 changed files with 36 additions and 40 deletions
+1 -1
View File
@@ -31,7 +31,7 @@
"axios": "^1.13.6", "axios": "^1.13.6",
"dompurify": "^3.3.3", "dompurify": "^3.3.3",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"mail-parser-wasm": "^0.2.1", "mail-parser-wasm": "^0.2.2",
"naive-ui": "^2.44.1", "naive-ui": "^2.44.1",
"postal-mime": "^2.7.3", "postal-mime": "^2.7.3",
"vooks": "^0.2.12", "vooks": "^0.2.12",
+5 -5
View File
@@ -36,8 +36,8 @@ importers:
specifier: ^3.10.1 specifier: ^3.10.1
version: 3.10.1 version: 3.10.1
mail-parser-wasm: mail-parser-wasm:
specifier: ^0.2.1 specifier: ^0.2.2
version: 0.2.1 version: 0.2.2
naive-ui: naive-ui:
specifier: ^2.44.1 specifier: ^2.44.1
version: 2.44.1(vue@3.5.30(typescript@5.4.5)) version: 2.44.1(vue@3.5.30(typescript@5.4.5))
@@ -2355,8 +2355,8 @@ packages:
magic-string@0.30.21: magic-string@0.30.21:
resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
mail-parser-wasm@0.2.1: mail-parser-wasm@0.2.2:
resolution: {integrity: sha512-ba1s8Ah9UI0AhEGCzf61h0wYOE4Wg/iceRZ7GCFrEldJjf3AAIDFdZVK853nwxIVE/bLnr0dJzrR7RxB9aGSlA==} resolution: {integrity: sha512-Am8xdpbDFkMBMOLW5ncTgIMT4ikCG7v42S02oXkUHwSvF00xn/LvWsWCnp2BY9Jlmy30Dq7cT3V3R8gTbr005w==}
math-intrinsics@1.1.0: math-intrinsics@1.1.0:
resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
@@ -5570,7 +5570,7 @@ snapshots:
dependencies: dependencies:
'@jridgewell/sourcemap-codec': 1.5.5 '@jridgewell/sourcemap-codec': 1.5.5
mail-parser-wasm@0.2.1: {} mail-parser-wasm@0.2.2: {}
math-intrinsics@1.1.0: {} math-intrinsics@1.1.0: {}
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "mail-parser-wasm" name = "mail-parser-wasm"
version = "0.2.1" version = "0.2.2"
edition = "2021" edition = "2021"
description = "A simple mail parser for wasm" description = "A simple mail parser for wasm"
license = "MIT" license = "MIT"
+23 -32
View File
@@ -101,38 +101,29 @@ impl MessageResult {
pub fn parse_attachment(message: &mail_parser::Message) -> Vec<AttachmentResult> { pub fn parse_attachment(message: &mail_parser::Message) -> Vec<AttachmentResult> {
let mut attachments: Vec<AttachmentResult> = Vec::new(); let mut attachments: Vec<AttachmentResult> = Vec::new();
for attachment in message.attachments() { for attachment in message.attachments() {
if !attachment.is_message() { attachments.push(AttachmentResult {
attachments.push(AttachmentResult { content_id: attachment
content_id: attachment .content_id()
.content_id() .map(|id| id.to_owned())
.map(|id| id.to_owned()) .unwrap_or(String::new()),
.unwrap_or(String::new()), content_type: attachment
content_type: attachment .content_type()
.content_type() .map(|ct| {
.map(|ct| { let c_type = ct.c_type.clone().into_owned();
let c_type = ct.c_type.clone().into_owned(); let c_subtype = ct.c_subtype.clone();
let c_subtype = ct.c_subtype.clone(); if c_subtype.is_none() {
if c_subtype.is_none() { return c_type;
return c_type; } else {
} else { return format!("{}/{}", c_type, c_subtype.unwrap());
return format!("{}/{}", c_type, c_subtype.unwrap()); }
} })
}) .unwrap_or(String::new()),
.unwrap_or(String::new()), filename: attachment
filename: attachment .attachment_name()
.attachment_name() .map(|name| name.to_owned())
.map(|name| name.to_owned()) .unwrap_or(String::new()),
.unwrap_or(String::new()), content: attachment.contents().to_vec(),
content: attachment.contents().to_vec(), });
});
} else {
attachments.append(
&mut attachment
.message()
.map(|msg| parse_attachment(msg))
.unwrap_or(Vec::new()),
);
}
} }
attachments attachments
} }
+5
View File
@@ -0,0 +1,5 @@
mail_parser_wasm_bg.wasm
mail_parser_wasm_bg.wasm.d.ts
mail_parser_wasm.js
mail_parser_wasm.d.ts
README.md
+1 -1
View File
@@ -7,7 +7,7 @@
"url": "https://github.com/dreamhunter2333/cloudflare_temp_email", "url": "https://github.com/dreamhunter2333/cloudflare_temp_email",
"directory": "mail-parser-wasm" "directory": "mail-parser-wasm"
}, },
"version": "0.2.1", "version": "0.2.2",
"license": "MIT", "license": "MIT",
"files": [ "files": [
"mail_parser_wasm_bg.wasm", "mail_parser_wasm_bg.wasm",