@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow username changes which modify letter case to go through as valid

Summary:
Fixes T13446. Currently, the validation logic here rejects a rename like "alice" to "ALICE" (which changes only letter case) but this is a permissible rename.

Allow collisions that collide with the same user to permit this rename.

Also, fix an issue where an empty rename was treated improperly.

Test Plan:
- Renamed "alice" to "ALICE".
- Before: username collision error.
- After: clean rename.
- Renamed "alice" to "orange" (an existing user). Got an error.
- Renamed "alice" to "", "!@#$", etc (invalid usernames). Got sensible errors.

Maniphest Tasks: T13446

Differential Revision: https://secure.phabricator.com/D20890

+15 -6
+15 -6
src/applications/people/xaction/PhabricatorUserUsernameTransaction.php
··· 71 71 } 72 72 73 73 if (!strlen($new)) { 74 - $errors[] = $this->newRequiredError( 75 - pht('New username is required.'), $xaction); 74 + $errors[] = $this->newInvalidError( 75 + pht('New username is required.'), 76 + $xaction); 76 77 } else if (!PhabricatorUser::validateUsername($new)) { 77 78 $errors[] = $this->newInvalidError( 78 - PhabricatorUser::describeValidUsername(), $xaction); 79 + PhabricatorUser::describeValidUsername(), 80 + $xaction); 79 81 } 80 82 81 83 $user = id(new PhabricatorPeopleQuery()) 82 84 ->setViewer(PhabricatorUser::getOmnipotentUser()) 83 85 ->withUsernames(array($new)) 84 86 ->executeOne(); 85 - 86 87 if ($user) { 87 - $errors[] = $this->newInvalidError( 88 - pht('Another user already has that username.'), $xaction); 88 + // See T13446. We may be changing the letter case of a username, which 89 + // is a perfectly fine edit. 90 + $is_self = ($user->getPHID() === $object->getPHID()); 91 + if (!$is_self) { 92 + $errors[] = $this->newInvalidError( 93 + pht( 94 + 'Another user already has the username "%s".', 95 + $new), 96 + $xaction); 97 + } 89 98 } 90 99 91 100 }