diff --git a/h/schemas/validators.py b/h/schemas/validators.py index 83924b942cd..9c7811281ed 100644 --- a/h/schemas/validators.py +++ b/h/schemas/validators.py @@ -6,29 +6,11 @@ import colander -# Regex for email addresses. -# -# Taken from Chromium and derived from the WhatWG HTML spec -# (4.10.7.1.5 E-Mail state). -# -# This was chosen because it is a widely used and relatively simple pattern. -# Unlike `colander.Email` it supports International Domain Names (IDNs) in -# Punycode form. -HTML5_EMAIL_REGEX = ( - "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@" "[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$" -) - - -class Email(colander.Regex): - """ - Validator for email addresses. - - This is a replacement for `colander.Email` which rejects certain valid email - addresses (see https://github.com/hypothesis/h/issues/4662). - """ - - def __init__(self, msg="Invalid email address."): - super(Email, self).__init__(HTML5_EMAIL_REGEX, msg=msg) +class Email(colander.Email): + def __init__(self, *args, **kwargs): + if "msg" not in kwargs: + kwargs["msg"] = "Invalid email address." + super(Email, self).__init__(*args, **kwargs) class Length(colander.Length):