From 3f1d800e90b71aa830085ff4684e7d6f6e0b13e9 Mon Sep 17 00:00:00 2001 From: Dream Hunter Date: Sat, 4 Jul 2026 16:56:12 +0800 Subject: [PATCH] fix: validate AI extracted link domains (#1075) * fix: validate AI extracted link domains * fix: validate extracted links against full email content * refactor: simplify AI link domain guard * refactor: keep AI domain fix prompt-only --- CHANGELOG.md | 1 + CHANGELOG_EN.md | 1 + worker/src/email/ai_extract.ts | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37277b82..4f807961 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Bug Fixes +- fix: |AI 提取| 强化提示词,要求 AI 保持邮件原始链接域名,避免小模型改写验证链接域名导致错误跳转(issue #1072) - fix: |AI 提取| HTML-only 邮件在发送给 Workers AI 前会先压缩为可读文本,避免样式模板过长导致验证码位于 4000 字截断之后而无法识别 - fix: |Frontend| 移动端 Header 增加页头内边距,避免标题、菜单按钮与屏幕边缘过近 diff --git a/CHANGELOG_EN.md b/CHANGELOG_EN.md index 88c5bbd2..89726648 100644 --- a/CHANGELOG_EN.md +++ b/CHANGELOG_EN.md @@ -12,6 +12,7 @@ ### Bug Fixes +- fix: |AI Extract| Strengthen the prompt to keep original link domains from the email, preventing small models from rewriting verification-link domains (issue #1072) - fix: |AI Extract| Convert HTML-only mail bodies into compact readable text before sending them to Workers AI, preventing long templates from pushing verification codes past the 4000-character truncation window - fix: |Frontend| Add mobile Header page padding so the title and menu button no longer sit too close to the screen edge diff --git a/worker/src/email/ai_extract.ts b/worker/src/email/ai_extract.ts index 2d891ab2..1857f8ea 100644 --- a/worker/src/email/ai_extract.ts +++ b/worker/src/email/ai_extract.ts @@ -75,7 +75,8 @@ If the extracted content is in markdown link format [text](url): 2. **Single Selection**: Choose ONLY ONE type based on the highest priority match 3. **Real Data Only**: Never invent, guess, or fabricate content 4. **Complete URLs**: Links must be full, valid URLs as they appear in the email -5. **Clean Extraction**: Return only the raw extracted content, no extra text +5. **No Domain Modification**: Never modify, rewrite, or substitute URL domains. If the exact URL domain is uncertain, return none +6. **Clean Extraction**: Return only the raw extracted content, no extra text # Output Format (JSON only) {