Make ACTOR_ADDRESS_RE more strict
This commit is contained in:
parent
af332283ed
commit
1511b5f22b
1 changed files with 8 additions and 1 deletions
|
@ -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<username>[\w\.-]+)@(?P<hostname>[\w\.-]+)";
|
||||
const ACTOR_ADDRESS_RE: &str = r"^(?P<username>[\w\.-]+)@(?P<hostname>[\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::<ActorAddress>();
|
||||
assert_eq!(result.is_err(), true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue