Skip to content

Commit

Permalink
[DisplayAction] Don't return redirect error codes (#1359)
Browse files Browse the repository at this point in the history
This might lead to redirect loops.

See
#1071 (comment)

Cherry-picked from eb21d6f.
  • Loading branch information
somini authored and logmanoriginal committed Dec 1, 2019
1 parent 02dd778 commit 60768b4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions actions/DisplayAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
*/

class DisplayAction extends ActionAbstract {
private function get_return_code($error) {
$returnCode = $error->getCode();
if ($returnCode === 301 || $returnCode === 302) {
# Don't pass redirect codes to the exterior
$returnCode = 508;
}
return $returnCode;
}

public function execute() {
$bridge = array_key_exists('bridge', $this->userData) ? $this->userData['bridge'] : null;

Expand Down Expand Up @@ -181,7 +190,7 @@ public function execute() {

$items[] = $item;
} elseif(Configuration::getConfig('error', 'output') === 'http') {
header('Content-Type: text/html', true, $e->getCode());
header('Content-Type: text/html', true, get_return_code($e));
die(buildTransformException($e, $bridge));
}
}
Expand Down Expand Up @@ -213,7 +222,7 @@ public function execute() {

$items[] = $item;
} elseif(Configuration::getConfig('error', 'output') === 'http') {
header('Content-Type: text/html', true, $e->getCode());
header('Content-Type: text/html', true, get_return_code($e));
die(buildTransformException($e, $bridge));
}
}
Expand Down

0 comments on commit 60768b4

Please sign in to comment.