[DisplayAction] Don't return redirect error codes (#1359)

This might lead to redirect loops.

See
https://github.com/RSS-Bridge/rss-bridge/pull/1071#issuecomment-515632848

Cherry-picked from eb21d6f.
This commit is contained in:
somini 2019-12-01 10:13:57 +00:00 committed by LogMANOriginal
parent 02dd778124
commit 60768b4885

View file

@ -12,6 +12,15 @@
*/ */
class DisplayAction extends ActionAbstract { 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() { public function execute() {
$bridge = array_key_exists('bridge', $this->userData) ? $this->userData['bridge'] : null; $bridge = array_key_exists('bridge', $this->userData) ? $this->userData['bridge'] : null;
@ -181,7 +190,7 @@ class DisplayAction extends ActionAbstract {
$items[] = $item; $items[] = $item;
} elseif(Configuration::getConfig('error', 'output') === 'http') { } 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)); die(buildTransformException($e, $bridge));
} }
} }
@ -213,7 +222,7 @@ class DisplayAction extends ActionAbstract {
$items[] = $item; $items[] = $item;
} elseif(Configuration::getConfig('error', 'output') === 'http') { } 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)); die(buildTransformException($e, $bridge));
} }
} }