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

Sanitize username early, and early reject invalid ones #434

Merged
merged 2 commits into from
Jun 15, 2024

Conversation

dwfreed
Copy link
Member

@dwfreed dwfreed commented Jun 13, 2024

This ensures [ won't appear in the various rejection snotes, and invalid username characters only appear in the snote announcing their rejection.

Supersedes #433 and #381
Fixes #334

This ensures we don't allow [ in usernames anywhere.  This also adds the
tilde early, which simplifies a lot of things, and fixes an issue with
username K-Lines on IsNoTilde users.
This way invalid characters in usernames only appear in this snote, and
all other rejection snotes will always have clean usernames.
@dwfreed dwfreed force-pushed the dwfreed/always-sanitize-username branch 2 times, most recently from beffef4 to 5a98757 Compare June 13, 2024 11:59
@glguy
Copy link
Collaborator

glguy commented Jun 13, 2024

I believe that we need to test that the new [-free username is not empty now. Before the change I get "invalid username" trying this. After the change I seem to be able to get an empty username

ircd/s_user.c Outdated

myusername[i] = '\0';
notildeusername[o] = '\0';

Copy link
Member

Choose a reason for hiding this comment

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

That could be accomplished by testing if o is still zero here.

@dwfreed dwfreed force-pushed the dwfreed/always-sanitize-username branch from 5a98757 to 62e860d Compare June 13, 2024 20:18
@dwfreed
Copy link
Member Author

dwfreed commented Jun 13, 2024

Fixed by moving the valid_username test to after the sanitization. It'll look like they have an empty username in the snote, but that's no worse than it was before.

Copy link
Collaborator

@glguy glguy left a comment

Choose a reason for hiding this comment

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

Works in my test instance; format strings seem correct

@dwfreed dwfreed merged commit e639f5b into main Jun 15, 2024
9 checks passed
@dwfreed dwfreed deleted the dwfreed/always-sanitize-username branch June 15, 2024 22:42
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.

pre-sanitise usernames are logged in SNO_BANNED
4 participants