Skip to content

Commit 5d05a4d

Browse files
atrakhConvex, Inc.
authored and
Convex, Inc.
committed
Validate email address when invites are sent (#26866)
GitOrigin-RevId: d8c5833c65ec684e090df30483a7199a44853bb7
1 parent 4cb33d1 commit 5d05a4d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

crates/common/src/errors.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,19 @@ use value::{
3838

3939
use crate::metrics::log_errors_reported_total;
4040

41+
// Regex to match emails from https://emailregex.com/
42+
pub static EMAIL_REGEX: LazyLock<Regex> = LazyLock::new(|| {
43+
Regex::new(r#"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"#).unwrap()
44+
});
45+
4146
/// Replacers for PII in errors before reporting to thirdparty services
4247
/// (sentry/datadog)
4348
static PII_REPLACEMENTS: LazyLock<Vec<(Regex, &'static str)>> = LazyLock::new(|| {
4449
vec![
4550
// Regex to match PII where we show the object that doesn't match the
4651
// validator.
4752
(Regex::new(r"(?s)Object:.*Validator").unwrap(), "Validator"),
48-
// Regex to match emails from https://emailregex.com/
49-
(
50-
Regex::new(r#"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"#).unwrap(),
51-
"*****@*****.***",
52-
),
53+
(EMAIL_REGEX.clone(), "*****@*****.***"),
5354
]
5455
});
5556

0 commit comments

Comments
 (0)