diff --git a/validator/Cargo.toml b/validator/Cargo.toml index 212cf1e6..bb341f17 100644 --- a/validator/Cargo.toml +++ b/validator/Cargo.toml @@ -12,7 +12,7 @@ readme = "../README.md" [dependencies] url = "2" -regex = "1" +regex = { version = "1", default-features = false, features = ["std"] } lazy_static = "1" idna = "0.2" serde = "1" diff --git a/validator/src/validation/email.rs b/validator/src/validation/email.rs index 0b386eba..8250013c 100644 --- a/validator/src/validation/email.rs +++ b/validator/src/validation/email.rs @@ -9,12 +9,12 @@ lazy_static! { // Regex from the specs // https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address // It will mark esoteric email addresses like quoted string as invalid - static ref EMAIL_USER_RE: Regex = Regex::new(r"^(?i)[a-z0-9.!#$%&'*+/=?^_`{|}~-]+\z").unwrap(); + static ref EMAIL_USER_RE: Regex = Regex::new(r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+\z").unwrap(); static ref EMAIL_DOMAIN_RE: Regex = Regex::new( - r"(?i)^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$" + r"^[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])?)*$" ).unwrap(); // literal form, ipv4 or ipv6 address (SMTP 4.1.3) - static ref EMAIL_LITERAL_RE: Regex = Regex::new(r"(?i)\[([A-f0-9:\.]+)\]\z").unwrap(); + static ref EMAIL_LITERAL_RE: Regex = Regex::new(r"\[([a-fA-F0-9:\.]+)\]\z").unwrap(); } /// Validates whether the given string is an email based on the [HTML5 spec](https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address). diff --git a/validator_derive/Cargo.toml b/validator_derive/Cargo.toml index a7d2201c..8e784642 100644 --- a/validator_derive/Cargo.toml +++ b/validator_derive/Cargo.toml @@ -24,7 +24,7 @@ proc-macro2 = "1" proc-macro-error = "1" if_chain = "1" validator_types = { version = "0.16", path = "../validator_types" } -regex = "1.5.5" +regex = { version = "1.5.5", default-features = false, features = ["std"] } lazy_static = "1"