3 final class PhabricatorUserTestCase
extends PhabricatorTestCase
{
5 public function testUsernameValidation() {
16 // These are silly, but permitted.
22 // These are not permitted because they make capturing @mentions
26 // We can never allow these because they invalidate usernames as tokens
27 // in commit messages ("Reviewers: alincoln, usgrant"), or as parameters
28 // in URIs ("/p/alincoln/", "?user=alincoln"), or make them unsafe in
29 // HTML. Theoretically we escape all the HTML/URI stuff, but these
30 // restrictions make attacks more difficult and are generally reasonable,
31 // since usernames like "<^, ,^>" don't seem very important to support.
40 "username\n" => false,
41 "user\nname" => false,
42 "\nusername" => false,
43 "username\r" => false,
44 "user\rname" => false,
45 "\rusername" => false,
48 foreach ($map as $name => $expect) {
51 PhabricatorUser
::validateUsername($name),
52 pht("Validity of '%s'.", $name));