allow contact email to be case sensitive
This commit is contained in:
parent
a17e81a8f1
commit
fdfa286d3e
|
@ -409,7 +409,7 @@ def create_contact_route(alias_id):
|
||||||
|
|
||||||
contact_name, contact_email = full_address.display_name, full_address.address
|
contact_name, contact_email = full_address.display_name, full_address.address
|
||||||
|
|
||||||
contact_email = sanitize_email(contact_email)
|
contact_email = sanitize_email(contact_email, not_lower=True)
|
||||||
|
|
||||||
# already been added
|
# already been added
|
||||||
contact = Contact.get_by(alias_id=alias.id, website_email=contact_email)
|
contact = Contact.get_by(alias_id=alias.id, website_email=contact_email)
|
||||||
|
|
|
@ -66,9 +66,11 @@ def encode_url(url):
|
||||||
return urllib.parse.quote(url, safe="")
|
return urllib.parse.quote(url, safe="")
|
||||||
|
|
||||||
|
|
||||||
def sanitize_email(email_address: str) -> str:
|
def sanitize_email(email_address: str, not_lower=False) -> str:
|
||||||
if email_address:
|
if email_address:
|
||||||
return email_address.lower().strip().replace(" ", "").replace("\n", " ")
|
email_address = email_address.strip().replace(" ", "").replace("\n", " ")
|
||||||
|
if not not_lower:
|
||||||
|
email_address = email_address.lower()
|
||||||
return email_address
|
return email_address
|
||||||
|
|
||||||
|
|
||||||
|
|
3
cron.py
3
cron.py
|
@ -656,7 +656,8 @@ def sanity_check():
|
||||||
LOG.e("Contact %s reply-email not sanitized", contact)
|
LOG.e("Contact %s reply-email not sanitized", contact)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
sanitize_email(contact.website_email) != contact.website_email
|
sanitize_email(contact.website_email, not_lower=True)
|
||||||
|
!= contact.website_email
|
||||||
and contact.created_at > contact_email_sanity_date
|
and contact.created_at > contact_email_sanity_date
|
||||||
):
|
):
|
||||||
LOG.e("Contact %s website-email not sanitized", contact)
|
LOG.e("Contact %s website-email not sanitized", contact)
|
||||||
|
|
|
@ -180,7 +180,7 @@ def get_or_create_contact(from_header: str, mail_from: str, alias: Alias) -> Con
|
||||||
# either reuse a contact with empty email or create a new contact with empty email
|
# either reuse a contact with empty email or create a new contact with empty email
|
||||||
contact_email = ""
|
contact_email = ""
|
||||||
|
|
||||||
contact_email = sanitize_email(contact_email)
|
contact_email = sanitize_email(contact_email, not_lower=True)
|
||||||
|
|
||||||
if contact_name and "\x00" in contact_name:
|
if contact_name and "\x00" in contact_name:
|
||||||
LOG.w("issue with contact name %s", contact_name)
|
LOG.w("issue with contact name %s", contact_name)
|
||||||
|
@ -300,10 +300,10 @@ def replace_header_when_forward(msg: Message, alias: Alias, header: str):
|
||||||
full_addresses += address.parse_list(h)
|
full_addresses += address.parse_list(h)
|
||||||
|
|
||||||
for full_address in full_addresses:
|
for full_address in full_addresses:
|
||||||
contact_email = sanitize_email(full_address.address)
|
contact_email = sanitize_email(full_address.address, not_lower=True)
|
||||||
|
|
||||||
# no transformation when alias is already in the header
|
# no transformation when alias is already in the header
|
||||||
if contact_email == alias.email:
|
if contact_email.lower() == alias.email:
|
||||||
new_addrs.append(full_address.full_spec())
|
new_addrs.append(full_address.full_spec())
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -1545,13 +1545,15 @@ def handle_bounce_reply_phase(envelope, msg: Message, email_log: EmailLog):
|
||||||
bounce_info = get_mailbox_bounce_info(msg)
|
bounce_info = get_mailbox_bounce_info(msg)
|
||||||
if bounce_info:
|
if bounce_info:
|
||||||
Bounce.create(
|
Bounce.create(
|
||||||
email=sanitize_email(contact.website_email),
|
email=sanitize_email(contact.website_email, not_lower=True),
|
||||||
info=bounce_info.as_bytes().decode(),
|
info=bounce_info.as_bytes().decode(),
|
||||||
commit=True,
|
commit=True,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
LOG.w("cannot get bounce info, debug at %s", save_email_for_debugging(msg))
|
LOG.w("cannot get bounce info, debug at %s", save_email_for_debugging(msg))
|
||||||
Bounce.create(email=sanitize_email(contact.website_email), commit=True)
|
Bounce.create(
|
||||||
|
email=sanitize_email(contact.website_email, not_lower=True), commit=True
|
||||||
|
)
|
||||||
|
|
||||||
# Store the bounced email
|
# Store the bounced email
|
||||||
# generate a name for the email
|
# generate a name for the email
|
||||||
|
|
Loading…
Reference in New Issue