mirror of
https://github.com/simple-login/app.git
synced 2024-09-27 20:31:30 +02:00
make sure reply-email only uses ascii-encoded char
This commit is contained in:
parent
ed22701cbe
commit
75c3fa1c11
@ -39,7 +39,7 @@ from app.dns_utils import get_mx_domains
|
|||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
from app.models import Mailbox, User, SentAlert, CustomDomain, SLDomain, Contact
|
from app.models import Mailbox, User, SentAlert, CustomDomain, SLDomain, Contact
|
||||||
from app.utils import random_string
|
from app.utils import random_string, convert_to_id
|
||||||
|
|
||||||
|
|
||||||
def render(template_name, **kwargs) -> str:
|
def render(template_name, **kwargs) -> str:
|
||||||
@ -739,6 +739,11 @@ def generate_reply_email(contact_email: str) -> str:
|
|||||||
# control char: 4 chars (ra+, +)
|
# control char: 4 chars (ra+, +)
|
||||||
# random suffix: max 10 chars
|
# random suffix: max 10 chars
|
||||||
# maximum: 64
|
# maximum: 64
|
||||||
|
|
||||||
|
# make sure contact_email can be ascii-encoded
|
||||||
|
contact_email = convert_to_id(contact_email)
|
||||||
|
# remove potential space
|
||||||
|
contact_email = contact_email.replace(" ", "")
|
||||||
contact_email = contact_email[:45]
|
contact_email = contact_email[:45]
|
||||||
contact_email = contact_email.replace("@", ".at.")
|
contact_email = contact_email.replace("@", ".at.")
|
||||||
|
|
||||||
|
@ -403,6 +403,9 @@ def test_generate_reply_email(flask_client):
|
|||||||
assert reply_email.startswith("ra+")
|
assert reply_email.startswith("ra+")
|
||||||
assert reply_email.endswith(EMAIL_DOMAIN)
|
assert reply_email.endswith(EMAIL_DOMAIN)
|
||||||
|
|
||||||
|
reply_email = generate_reply_email("👌汉字@example.org")
|
||||||
|
assert reply_email.startswith("ra+YiZi.at.example.org+")
|
||||||
|
|
||||||
|
|
||||||
def test_get_addrs_from_header():
|
def test_get_addrs_from_header():
|
||||||
msg = email.message_from_string("""To: abcd@test.org""")
|
msg = email.message_from_string("""To: abcd@test.org""")
|
||||||
|
Loading…
Reference in New Issue
Block a user