fix(backend): メールアドレスの形式が正しくなければ以降の処理を行わないように (#15320)
* Mod: バリデーションを追加 * 条件の修正 notつけわすれ * Update CHANGELOG.md
This commit is contained in:
parent
e2a55e2a31
commit
f3a4434830
@ -22,7 +22,7 @@
|
|||||||
- Fix: オブジェクトストレージの設定でPrefixを設定していなかった場合nullまたは空文字になる問題を修正
|
- Fix: オブジェクトストレージの設定でPrefixを設定していなかった場合nullまたは空文字になる問題を修正
|
||||||
- Fix: pgroongaでの検索時にはじめのキーワードのみが検索に使用される問題を修正
|
- Fix: pgroongaでの検索時にはじめのキーワードのみが検索に使用される問題を修正
|
||||||
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/886)
|
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/886)
|
||||||
|
- Fix: メールアドレスの形式が正しくなければ以降の処理を行わないように
|
||||||
|
|
||||||
## 2025.2.0
|
## 2025.2.0
|
||||||
|
|
||||||
|
@ -164,6 +164,13 @@ export class EmailService {
|
|||||||
available: boolean;
|
available: boolean;
|
||||||
reason: null | 'used' | 'format' | 'disposable' | 'mx' | 'smtp' | 'banned' | 'network' | 'blacklist';
|
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({
|
const exist = await this.userProfilesRepository.countBy({
|
||||||
emailVerified: true,
|
emailVerified: true,
|
||||||
email: emailAddress,
|
email: emailAddress,
|
||||||
|
@ -38,6 +38,14 @@ export class UtilityService {
|
|||||||
return this.punyHost(uri) === this.toPuny(this.config.host);
|
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
|
@bindThis
|
||||||
public isBlockedHost(blockedHosts: string[], host: string | null): boolean {
|
public isBlockedHost(blockedHosts: string[], host: string | null): boolean {
|
||||||
if (host == null) return false;
|
if (host == null) return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user