mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-05 07:27:27 +08:00
feat: only allow address [a-z0-9] (#347)
This commit is contained in:
@@ -72,7 +72,7 @@ const { locale, t } = useI18n({
|
|||||||
login: 'Login',
|
login: 'Login',
|
||||||
pleaseGetNewEmail: 'Please login or click "Get New Email" button to get a new email address',
|
pleaseGetNewEmail: 'Please login or click "Get New Email" button to get a new email address',
|
||||||
getNewEmail: 'Create New Email',
|
getNewEmail: 'Create New Email',
|
||||||
getNewEmailTip1: 'Please input the email you want to use. only allow ., a-z, A-Z and 0-9',
|
getNewEmailTip1: 'Please input the email you want to use. only allow a-z and 0-9',
|
||||||
getNewEmailTip2: 'Levaing it blank will generate a random email address.',
|
getNewEmailTip2: 'Levaing it blank will generate a random email address.',
|
||||||
getNewEmailTip3: 'You can choose a domain from the dropdown list.',
|
getNewEmailTip3: 'You can choose a domain from the dropdown list.',
|
||||||
credential: 'Email Address Credential',
|
credential: 'Email Address Credential',
|
||||||
@@ -87,7 +87,7 @@ const { locale, t } = useI18n({
|
|||||||
login: '登录',
|
login: '登录',
|
||||||
pleaseGetNewEmail: '请"登录"或点击 "注册新邮箱" 按钮来获取一个新的邮箱地址',
|
pleaseGetNewEmail: '请"登录"或点击 "注册新邮箱" 按钮来获取一个新的邮箱地址',
|
||||||
getNewEmail: '创建新邮箱',
|
getNewEmail: '创建新邮箱',
|
||||||
getNewEmailTip1: '请输入你想要使用的邮箱地址, 只允许 ., a-z, A-Z, 0-9',
|
getNewEmailTip1: '请输入你想要使用的邮箱地址, 只允许 a-z, 0-9',
|
||||||
getNewEmailTip2: '留空将会生成一个随机的邮箱地址。',
|
getNewEmailTip2: '留空将会生成一个随机的邮箱地址。',
|
||||||
getNewEmailTip3: '你可以从下拉列表中选择一个域名。',
|
getNewEmailTip3: '你可以从下拉列表中选择一个域名。',
|
||||||
credential: '邮箱地址凭据',
|
credential: '邮箱地址凭据',
|
||||||
@@ -110,7 +110,7 @@ const generateName = async () => {
|
|||||||
.split('@')[0]
|
.split('@')[0]
|
||||||
.replace(/\s+/g, '.')
|
.replace(/\s+/g, '.')
|
||||||
.replace(/\.{2,}/g, '.')
|
.replace(/\.{2,}/g, '.')
|
||||||
.replace(/[^a-zA-Z0-9.]/g, '')
|
.replace(/[^a-z0-9]/g, '')
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error(error.message || "error");
|
message.error(error.message || "error");
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const newAddress = async (
|
|||||||
checkLengthByConfig: boolean = true
|
checkLengthByConfig: boolean = true
|
||||||
): Promise<{ address: string, jwt: string }> => {
|
): Promise<{ address: string, jwt: string }> => {
|
||||||
// remove special characters
|
// remove special characters
|
||||||
name = name.replace(/[^a-zA-Z0-9.]/g, '')
|
name = name.replace(/[^a-z0-9]/g, '')
|
||||||
// name min length min 1
|
// name min length min 1
|
||||||
const minAddressLength = Math.max(
|
const minAddressLength = Math.max(
|
||||||
checkLengthByConfig ? getIntValue(c.env.MIN_ADDRESS_LEN, 1) : 1,
|
checkLengthByConfig ? getIntValue(c.env.MIN_ADDRESS_LEN, 1) : 1,
|
||||||
|
|||||||
@@ -38,9 +38,10 @@ api.delete('/api/mails/:id', async (c) => {
|
|||||||
}
|
}
|
||||||
const { address } = c.get("jwtPayload")
|
const { address } = c.get("jwtPayload")
|
||||||
const { id } = c.req.param();
|
const { id } = c.req.param();
|
||||||
|
// TODO: add toLowerCase() to handle old data
|
||||||
const { success } = await c.env.DB.prepare(
|
const { success } = await c.env.DB.prepare(
|
||||||
`DELETE FROM raw_mails WHERE address = ? and id = ? `
|
`DELETE FROM raw_mails WHERE address = ? and id = ? `
|
||||||
).bind(address, id).run();
|
).bind(address.toLowerCase(), id).run();
|
||||||
return c.json({
|
return c.json({
|
||||||
success: success
|
success: success
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const COMMANDS = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: "new",
|
command: "new",
|
||||||
description: "新建邮箱地址, 如果要自定义邮箱地址, 请输入 /new <name>@<domain>, name [a-zA-Z0-9.] 有效"
|
description: "新建邮箱地址, 如果要自定义邮箱地址, 请输入 /new <name>@<domain>, name [a-z0-9] 有效"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: "address",
|
command: "address",
|
||||||
|
|||||||
Reference in New Issue
Block a user