Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ffi): Make is_room_alias_format_valid stricter #4234

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

jmartinesp
Copy link
Contributor

Previously this only used the Ruma checks, which only handled the initial # char and the domain part. With these changes, the name part is also validated, checking it's lowercase, with no whitespaces and containing only allowed chars, similar to what DisplayName::to_room_alias_name does.

  • Public API changes documented in changelogs (optional)

Signed-off-by:

@jmartinesp jmartinesp changed the title refactor(ffi): Make is_room_alias_format_valid more strict refactor(ffi): Make is_room_alias_format_valid stricter Nov 8, 2024
Previously this only used the Ruma checks, which only handled the initial `#` char and the domain part. With these changes, the name part is also validated, checking it's lowercase, with no whitespaces and containing only allowed chars, similar to what `DisplayName::to_room_alias_name` does.

Moved the code to the SDK crate so it can be properly tested.
Copy link

codecov bot commented Nov 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.91%. Comparing base (965a59d) to head (08bf5ae).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4234      +/-   ##
==========================================
+ Coverage   84.87%   84.91%   +0.04%     
==========================================
  Files         274      274              
  Lines       29677    29689      +12     
==========================================
+ Hits        25187    25211      +24     
+ Misses       4490     4478      -12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jmartinesp jmartinesp force-pushed the misc/improve-is-room-alias-format-valid branch from 8b6d2ee to 08bf5ae Compare November 8, 2024 09:26
@jmartinesp jmartinesp marked this pull request as ready for review November 8, 2024 10:40
@jmartinesp jmartinesp requested a review from a team as a code owner November 8, 2024 10:40
@jmartinesp jmartinesp requested review from stefanceriu and removed request for a team November 8, 2024 10:40
Copy link
Member

@stefanceriu stefanceriu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me but I can't help wonder if we should contribute this back up to Ruma

@jmartinesp
Copy link
Contributor Author

I think the id parsing checks were kept very 'light' for compatibility reasons, but I might be wrong. The only validation that seems to do anything besides checking the prefix seems to be user_id.

@jmartinesp jmartinesp enabled auto-merge (rebase) November 8, 2024 10:54
@jmartinesp jmartinesp merged commit 46232ee into main Nov 8, 2024
76 checks passed
@jmartinesp jmartinesp deleted the misc/improve-is-room-alias-format-valid branch November 8, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants