-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce valid email address for User email #308
base: develop
Are you sure you want to change the base?
Conversation
server/migrations/community/1a6175c78a10_email_address_format_check.py
Outdated
Show resolved
Hide resolved
I am not confident with this change and multi language support. |
@@ -29,6 +30,11 @@ def username_validation(form, field): | |||
) | |||
|
|||
|
|||
def email_format(form, field): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about extending Email() validator?
@@ -7,7 +7,7 @@ | |||
from typing import List, Optional | |||
import bcrypt | |||
from flask import current_app, request | |||
from sqlalchemy import or_, func | |||
from sqlalchemy import or_, func, CheckConstraint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need CheckConstraint?
|
||
def contains_email_invalid_characters(email: str) -> bool: | ||
"""Check for invalid characters for the email address""" | ||
invalid_characters = r"[ ;:’\–\—|,]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about two .
in username, how is this handled?
Do we have some sources about 'standard' emails validations?
"""Check if given text is in UTF-8 encoding""" | ||
try: | ||
text.encode("utf-8").decode("utf-8") | ||
return "�" not in text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the best way?
@harminius I suggest also to check db against invalid characters and non-utf8 mess, if you can pass me the queries |
resolves #2537
contains_email_invalid_characters
function only adds a few invalid characters, most of the others are caught by WTForms Email validatorTherefore, introducing a DB constraint with a definite list of invalid characters does not make much sense.