From 1511b5f22b7cb3c26363aa2f45fbd84632f41590 Mon Sep 17 00:00:00 2001 From: silverpill Date: Tue, 10 Jan 2023 22:51:32 +0000 Subject: [PATCH] Make ACTOR_ADDRESS_RE more strict --- src/webfinger/types.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/webfinger/types.rs b/src/webfinger/types.rs index 97ec29f..c3d4aa5 100644 --- a/src/webfinger/types.rs +++ b/src/webfinger/types.rs @@ -8,7 +8,7 @@ use serde::{Serialize, Deserialize}; use crate::errors::ValidationError; // See also: USERNAME_RE in models::profiles::validators -const ACTOR_ADDRESS_RE: &str = r"(?P[\w\.-]+)@(?P[\w\.-]+)"; +const ACTOR_ADDRESS_RE: &str = r"^(?P[\w\.-]+)@(?P[\w\.-]+)$"; pub const JRD_CONTENT_TYPE: &str = "application/jrd+json"; @@ -83,4 +83,11 @@ mod tests { assert_eq!(actor_address.hostname, "example.com"); assert_eq!(actor_address.to_string(), value); } + + #[test] + fn test_actor_address_parse_mention() { + let value = "@user_1@example.com"; + let result = value.parse::(); + assert_eq!(result.is_err(), true); + } }