Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F72602609
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
Tue, Jul 16, 02:48
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Jul 18, 02:48 (2 d)
Engine
blob
Format
Raw Data
Handle
19076026
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