Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2895520
PhabricatorUserTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorUserTestCase.php
View Options
<?php
final
class
PhabricatorUserTestCase
extends
PhabricatorTestCase
{
public
function
testUsernameValidation
(
)
{
$map
=
array
(
'alincoln'
=>
true
,
'alincoln69'
=>
true
,
'hd3'
=>
true
,
'Alincoln'
=>
true
,
'a.lincoln'
=>
true
,
'alincoln!'
=>
false
,
''
=>
false
,
// These are silly, but permitted.
'7'
=>
true
,
'0'
=>
true
,
'____'
=>
true
,
'-'
=>
true
,
// These are not permitted because they make capturing @mentions
// ambiguous.
'joe.'
=>
false
,
// We can never allow these because they invalidate usernames as tokens
// in commit messages ("Reviewers: alincoln, usgrant"), or as parameters
// in URIs ("/p/alincoln/", "?user=alincoln"), or make them unsafe in
// HTML. Theoretically we escape all the HTML/URI stuff, but these
// restrictions make attacks more difficult and are generally reasonable,
// since usernames like "<^, ,^>" don't seem very important to support.
'<script>'
=>
false
,
'a lincoln'
=>
false
,
' alincoln'
=>
false
,
'alincoln '
=>
false
,
'a,lincoln'
=>
false
,
'a&lincoln'
=>
false
,
'a/lincoln'
=>
false
,
"username\n"
=>
false
,
"user\nname"
=>
false
,
"\nusername"
=>
false
,
"username\r"
=>
false
,
"user\rname"
=>
false
,
"\rusername"
=>
false
,
)
;
foreach
(
$map
as
$name
=>
$expect
)
{
$this
->
assertEqual
(
$expect
,
PhabricatorUser
::
validateUsername
(
$name
)
,
pht
(
"Validity of '%s'."
,
$name
)
)
;
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Jan 19 2025, 21:34 (6 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129000
Default Alt Text
PhabricatorUserTestCase.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment