LemmyNet / activitypub-federation-rust

High-level Rust library for the Activitypub protocol
GNU Affero General Public License v3.0
432 stars 47 forks source link

Change username regex in webfinger #34

Closed Grafcube closed 1 year ago

Grafcube commented 1 year ago

This PR changes the regex used for username in extract_webfinger_name to include additional characters like '.' and '-'. This is the same regex used in Mastodon.

Some usernames may contain hyphens. The old regex made it impossible to get webfinger information for those usernames since it would always return an error.

There might be a better way to handle this though because as far as I can tell, the spec says nothing about what values are acceptable for preferredUsername so there may be some usernames with '+' or '%' or something else.

Nutomic commented 1 year ago

Good catch. Could you also include a link to the Mastodon regex as a comment for reference?

There might be a better way to handle this though because as far as I can tell, the spec says nothing about what values are acceptable for preferredUsername so there may be some usernames with '+' or '%' or something else.

The spec doesnt say a lot of things about the way things work in the real world. Taking it too literal would make things much more complicated for no benefit if no existing platform actually uses such possibilities.

Grafcube commented 1 year ago

Taking it too literal would make things much more complicated for no benefit if no existing platform actually uses such possibilities.

Fair enough. I have added a comment linking to the Mastodon source where the regex is from.

Nutomic commented 1 year ago

Thanks!