Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php final class AphrontRedirectResponseTestCase extends PhabricatorTestCase { public..
Decoded Output download
<?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);
}
}
}
}
}
?>
Did this file decode correctly?
Original Code
<?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);
}
}
}
}
}
Function Calls
None |
Stats
MD5 | 39d8fb7ff208361afbdd705ce9c341f1 |
Eval Count | 0 |
Decode Time | 73 ms |