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

Add support for wide characters in passwords. #2628

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

taniwallach
Copy link
Member

This is an attempt to address #1141 about problems with wide characters in passwords.

Login attempts where the password field contained most wide Unicode characters would trigger an error page and not just a failed login attempt. So would pages where an attempt was made to set a password with such a character. The error pages was triggered as crypt would die on most wide Unicode characters. However, there were apparently some which would work as a result of special handling in crypt for wide characters which could be downgraded to 8-bit characters.

For example the character ג in passwords would trigger the error.

In order to support wide characters in passwords while not breaking any passwords which worked before this change, a password will be encoded into UTF-8 before being sent to crypt only when crypt dies on the original string.

The crypt function cannot handle most wide (Unicode) characters,
but does handle some by attempting to downgrade to an 8-bit string.

In order to support wide characters in passwords while not breaking
any passwords which worked before this change, a password will be
encoded into UTF-8 before being sent to crypt only when crypt dies
on the original string.
Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

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

This should use the encode method of Mojo::Util (which is really just the Encode::encode method), rather than the Encode::utf8_encode method. The Encode::utf8_encode method should not be used anymore.

Also, the process that you have duplicated in three places should be made into a utility method in lib/WeBWorK/Utils.pm, and just called in all three places. The crypt method can just be replaced with this utility method making much cleaner code.

I have put in a pull request to your branch making these changes.

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