summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
author鴇峰 朔華 <160555157+sakuhanight@users.noreply.github.com>2025-02-16 18:41:33 +0900
committerGitHub <noreply@github.com>2025-02-16 09:41:33 +0000
commitf3a4434830ac4cc2d12f814f880d41ba7b81b87b (patch)
treee01470b38636bacd410b5143f5069a0e3f2be4d4 /packages/backend/src
parentfix(deps): update [frontend] update dependencies (#15504) (diff)
downloadsharkey-f3a4434830ac4cc2d12f814f880d41ba7b81b87b.tar.gz
sharkey-f3a4434830ac4cc2d12f814f880d41ba7b81b87b.tar.bz2
sharkey-f3a4434830ac4cc2d12f814f880d41ba7b81b87b.zip
fix(backend): メールアドレスの形式が正しくなければ以降の処理を行わないように (#15320)
* Mod: バリデーションを追加 * 条件の修正 notつけわすれ * Update CHANGELOG.md
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/EmailService.ts7
-rw-r--r--packages/backend/src/core/UtilityService.ts8
2 files changed, 15 insertions, 0 deletions
diff --git a/packages/backend/src/core/EmailService.ts b/packages/backend/src/core/EmailService.ts
index da198d0e42..45d7ea11e4 100644
--- a/packages/backend/src/core/EmailService.ts
+++ b/packages/backend/src/core/EmailService.ts
@@ -164,6 +164,13 @@ export class EmailService {
available: boolean;
reason: null | 'used' | 'format' | 'disposable' | 'mx' | 'smtp' | 'banned' | 'network' | 'blacklist';
}> {
+ if (!this.utilityService.validateEmailFormat(emailAddress)) {
+ return {
+ available: false,
+ reason: 'format',
+ };
+ }
+
const exist = await this.userProfilesRepository.countBy({
emailVerified: true,
email: emailAddress,
diff --git a/packages/backend/src/core/UtilityService.ts b/packages/backend/src/core/UtilityService.ts
index fcb750d3bf..23fb928ac9 100644
--- a/packages/backend/src/core/UtilityService.ts
+++ b/packages/backend/src/core/UtilityService.ts
@@ -38,6 +38,14 @@ export class UtilityService {
return this.punyHost(uri) === this.toPuny(this.config.host);
}
+ // メールアドレスのバリデーションを行う
+ // https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
+ @bindThis
+ public validateEmailFormat(email: string): boolean {
+ const regexp = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
+ return regexp.test(email);
+ }
+
@bindThis
public isBlockedHost(blockedHosts: string[], host: string | null): boolean {
if (host == null) return false;