Skip to content

Commit 679cb4c

Browse files
committed
fix: mask Telegram bot token
1 parent 629a32c commit 679cb4c

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

mail-vue/src/views/sys-setting/index.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@
531531
</div>
532532
</template>
533533
<div class="forward-set-body">
534-
<el-input :placeholder="$t('tgBotToken')" v-model="tgBotToken"></el-input>
534+
<el-input :placeholder="setting.tgBotToken || $t('tgBotToken')" v-model="tgBotToken"></el-input>
535535
<el-input-tag tag-type="warning" :placeholder="$t('toBotTokenDesc')" v-model="tgChatId"
536536
@add-tag="addChatTag"></el-input-tag>
537537
<el-input tag-type="warning" :placeholder="$t('customDomainDesc')" v-model="customDomain" ></el-input>
@@ -1064,7 +1064,7 @@ function closedSetBackground() {
10641064
10651065
function openTgSetting() {
10661066
tgBotStatus.value = setting.value.tgBotStatus
1067-
tgBotToken.value = setting.value.tgBotToken
1067+
tgBotToken.value = ''
10681068
customDomain.value = setting.value.customDomain
10691069
tgMsgFrom.value = setting.value.tgMsgFrom
10701070
tgMsgText.value = setting.value.tgMsgText
@@ -1205,14 +1205,14 @@ function saveS3() {
12051205
12061206
function tgBotSave() {
12071207
const form = {
1208-
tgBotToken: tgBotToken.value,
12091208
customDomain: customDomain.value,
12101209
tgBotStatus: tgBotStatus.value,
12111210
tgChatId: tgChatId.value + '',
12121211
tgMsgFrom: tgMsgFrom.value,
12131212
tgMsgText: tgMsgText.value,
12141213
tgMsgTo: tgMsgTo.value
12151214
}
1215+
if (tgBotToken.value) form.tgBotToken = tgBotToken.value
12161216
editSetting(form)
12171217
}
12181218
@@ -1468,6 +1468,7 @@ function change(e) {
14681468
delete settingForm.secretKey
14691469
delete settingForm.s3AccessKey
14701470
delete settingForm.s3SecretKey
1471+
delete settingForm.tgBotToken
14711472
delete settingForm.resendTokens
14721473
editSetting(settingForm, false)
14731474
}

mail-worker/src/service/setting-service.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ const settingService = {
100100

101101
settingRow.s3AccessKey = settingRow.s3AccessKey ? `${settingRow.s3AccessKey.slice(0, 12)}******` : null;
102102
settingRow.s3SecretKey = settingRow.s3SecretKey ? `${settingRow.s3SecretKey.slice(0, 12)}******` : null;
103+
settingRow.tgBotToken = settingRow.tgBotToken ? `${settingRow.tgBotToken.slice(0, 20)}******` : null;
103104
settingRow.hasR2 = !!c.env.r2
104105
settingRow.hasCfEmail = !!c.env.email
105106

mail-worker/src/service/telegram-service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const telegramService = {
5555
const inlineKeyboard = [
5656
[
5757
{
58-
text: '查看',
58+
text: 'View',
5959
web_app: { url: webAppUrl }
6060
}
6161
]

mail-worker/src/template/email-html.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default function emailHtmlTemplate(html, domain) {
77
document.querySelectorAll('script').forEach(script => script.remove());
88
html = document.toString();
99
html = html.replace(/{{domain}}/g, domainUtils.toOssDomain(domain) + '/');
10+
const safeHtmlJson = JSON.stringify(html).replace(/</g, '\\u003C');
1011

1112
return `<!DOCTYPE html>
1213
<html lang='en' >
@@ -127,7 +128,7 @@ export default function emailHtmlTemplate(html, domain) {
127128
}
128129
129130
// 使用示例
130-
const exampleHtml = \`${html}\`;
131+
const exampleHtml = ${safeHtmlJson};
131132
132133
// 渲染HTML
133134
renderHTML(exampleHtml);

0 commit comments

Comments
 (0)