Change username regex in webfinger

Changes the regex used for username in `extract_webfinger_name` to
include additional characters like '.' and '-'. This is the same regex
used in Mastodon.
This commit is contained in:
Grafcube 2023-04-01 16:02:57 +05:30
parent c56f526914
commit 1db2d49522
No known key found for this signature in database
GPG key ID: E383688F2878A440

View file

@ -71,8 +71,11 @@ where
T: Clone,
{
// TODO: would be nice if we could implement this without regex and remove the dependency
let regex = Regex::new(&format!("^acct:([a-zA-Z0-9_]{{3,}})@{}$", data.domain()))
.map_err(Error::other)?;
let regex = Regex::new(&format!(
"^acct:((?i)[a-z0-9_]+([a-z0-9_\\.-]+[a-z0-9_]+)?)@{}$",
data.domain()
))
.map_err(Error::other)?;
Ok(regex
.captures(query)
.and_then(|c| c.get(1))