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

Fix uppercase and Unicode username handling #2160

Closed
wants to merge 1 commit into from
Closed

Fix uppercase and Unicode username handling #2160

wants to merge 1 commit into from

Conversation

newbthenewbd
Copy link
Contributor

Here goes another attempt at getting #2138 merged.

This pull request differs from the previous one by having less messy commits and better improving how the filename is determined at the line 195 of User.php. According to my research, this is still needed because of the login plugin not making the username lowercase on registration, while according to my tests on Arch Linux, no duplicate files get created as $file->filename() gets called on a $file that was already named, as long as that file hasn't been saved with the wrong name, which should never be the case there.

Nevertheless, I shall soon be sending a pull request to the login plugin as well, making it properly convert the usernames to lowercase for filenames. If there is still an important reason to omit the line 195 change that I haven't noticed, that change can perhaps be omitted by somehow lining up a version of the login plugin that would have said pull request merged with a Grav version with the functional rest of this.

Less controversially, this pull request also adds a mb_strtolower() call in User::remove().

@mahagr
Copy link
Member

mahagr commented Sep 4, 2018

Looks much better. I will need to take a deeper look into this, but it looks good after a quick core review.

@@ -192,9 +192,9 @@ public function save()
if ($file) {
$username = $this->get('username');

if (!$file->filename()) {
if (!$file->filename() || $username != mb_strtolower($username)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this extra check for backwards compat ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If my memory doesn't fail me, this was meant to guarantee the creation of lowercase-named files, which could be named uppercase in the case of the files having been already assigned at this point, causing a handful of problems.

@mahagr mahagr self-requested a review May 7, 2019 06:19
@newbthenewbd
Copy link
Contributor Author

During the code restructuring in v1.6 most of the proposed functionality has been implemented, hence closing. The missing piece required to ensure full support for usernames with uppercase characters shall follow in a separate pull request.

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.

3 participants