From 3221f5ae3085a6b981b40afc6fd4bf7b624e6cb0 Mon Sep 17 00:00:00 2001 From: jiaxin Date: Tue, 14 Apr 2026 15:59:25 +0800 Subject: [PATCH] fix: lowercase configured address prefixes (#980) * fix: normalize address casing for password login Store new mailbox addresses in lowercase and migrate historical address data so mixed-case password logins can read inbox, sendbox, and settings consistently. * fix: only lowercase configured address prefixes Limit the #930 change to prefix normalization and document that existing mixed-case data must be migrated manually by users. --- CHANGELOG.md | 1 + CHANGELOG_EN.md | 1 + worker/src/common.ts | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b3871dd..137cb59a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ ### Bug Fixes - fix: |用户侧收件箱| 修复 `ENABLE_USER_DELETE_EMAIL` 关闭时用户中心仍显示删除按钮且仍可通过 `/user_api/mails/:id` 删除邮件的问题(#978) +- fix: |Address| 创建邮箱时统一将配置的前缀转为小写,避免生成包含大写前缀的地址;历史数据需用户自行迁移为小写(#930) - fix: |Admin| 修复 `/admin/address` 与 `/admin/users` 在使用完整邮箱(query 长度超过 50 字节)作为搜索条件时报错 `D1_ERROR: LIKE or GLOB pattern too complex` 的问题,长查询自动改用 `instr()` 绕开 D1 的 LIKE pattern 长度限制(#956) ### Improvements diff --git a/CHANGELOG_EN.md b/CHANGELOG_EN.md index 46c4048e..8b10e01a 100644 --- a/CHANGELOG_EN.md +++ b/CHANGELOG_EN.md @@ -16,6 +16,7 @@ ### Bug Fixes - fix: |User Mailbox| Fix an issue where the user center still showed delete actions and could still delete mail via `/user_api/mails/:id` when `ENABLE_USER_DELETE_EMAIL` was disabled (#978) +- fix: |Address| Lowercase configured prefixes when creating addresses to avoid generating mixed-case mailbox names; existing data must be migrated to lowercase manually by the user (#930) - fix: |Admin| Fix `D1_ERROR: LIKE or GLOB pattern too complex` on `/admin/address` and `/admin/users` when searching by full email address (query length pushes the LIKE pattern over D1's 50-byte limit). Long queries now fall back to `instr()` to bypass the LIKE pattern length cap (#956) ### Improvements diff --git a/worker/src/common.ts b/worker/src/common.ts index 4eb24737..2e503b27 100644 --- a/worker/src/common.ts +++ b/worker/src/common.ts @@ -728,13 +728,13 @@ export const commonGetUserRole = async ( export const getAddressPrefix = async (c: Context): Promise => { const user = c.get("userPayload"); if (!user) { - return getStringValue(c.env.PREFIX); + return getStringValue(c.env.PREFIX).trim().toLowerCase(); } const user_role = await commonGetUserRole(c, user.user_id); if (typeof user_role?.prefix === "string") { - return user_role.prefix; + return user_role.prefix.trim().toLowerCase(); } - return getStringValue(c.env.PREFIX); + return getStringValue(c.env.PREFIX).trim().toLowerCase(); } export const getAllowDomains = async (c: Context): Promise => {