Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F77476180
AphrontRedirectResponseTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Aug 14, 17:17
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Aug 16, 17:17 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
19874039
Attached To
rPH Phabricator
AphrontRedirectResponseTestCase.php
View Options
<?php
final
class
AphrontRedirectResponseTestCase
extends
PhabricatorTestCase
{
public
function
testLocalRedirectURIs
()
{
// Format a bunch of URIs for local and remote redirection, making sure
// we get the expected results.
$uris
=
array
(
'/a'
=>
array
(
'http://phabricator.example.com/a'
,
false
,
),
'a'
=>
array
(
false
,
false
,
),
'/
\\
evil.com'
=>
array
(
false
,
false
,
),
'http://www.evil.com/'
=>
array
(
false
,
'http://www.evil.com/'
,
),
'//evil.com'
=>
array
(
false
,
false
,
),
'//'
=>
array
(
false
,
false
,
),
''
=>
array
(
false
,
false
,
),
);
foreach
(
$uris
as
$input
=>
$cases
)
{
foreach
(
array
(
false
,
true
)
as
$idx
=>
$is_external
)
{
$expect
=
$cases
[
$idx
];
$caught
=
null
;
try
{
$result
=
AphrontRedirectResponse
::
getURIForRedirect
(
$input
,
$is_external
);
}
catch
(
Exception
$ex
)
{
$caught
=
$ex
;
}
if
(
$expect
===
false
)
{
$this
->
assertTrue
((
$caught
instanceof
Exception
),
$input
);
}
else
{
$this
->
assertEqual
(
null
,
$caught
,
$input
);
$this
->
assertEqual
(
$expect
,
$result
,
$input
);
}
}
}
}
}
Event Timeline
Log In to Comment