Fix redirection loop (#5143)

fixes #5133
This commit is contained in:
Johannes Meyer 2023-10-27 10:21:40 +02:00 committed by GitHub
commit a1cd968579
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 9 deletions

View File

@ -322,8 +322,10 @@ class Response extends Zend_Controller_Response_Http
if ($request->isXmlHttpRequest()) { if ($request->isXmlHttpRequest()) {
if ($redirectUrl !== null) { if ($redirectUrl !== null) {
if ($request->isGet() && Icinga::app()->getViewRenderer()->view->compact) { if ($request->isGet() && Icinga::app()->getViewRenderer()->view->compact) {
if ($redirectUrl->getParam('redirect') !== '__SELF__') {
$redirectUrl->getParams()->set('showCompact', true); $redirectUrl->getParams()->set('showCompact', true);
} }
}
$encodedRedirectUrl = rawurlencode($redirectUrl->getAbsoluteUrl()); $encodedRedirectUrl = rawurlencode($redirectUrl->getAbsoluteUrl());

View File

@ -637,6 +637,7 @@
var redirectionUrl = icinga.utils.addUrlFlag(url, 'renderLayout'); var redirectionUrl = icinga.utils.addUrlFlag(url, 'renderLayout');
var r = this.loadUrl(redirectionUrl, $('#layout')); var r = this.loadUrl(redirectionUrl, $('#layout'));
r.historyUrl = url; r.historyUrl = url;
r.referrer = referrer;
if (parts.length) { if (parts.length) {
r.loadNext = parts; r.loadNext = parts;
} else if (!! document.location.hash) { } else if (!! document.location.hash) {
@ -789,14 +790,9 @@
this.icinga.ui.setWindowId(windowId); this.icinga.ui.setWindowId(windowId);
} }
var referrer = req.referrer;
if (typeof referrer === 'undefined') {
referrer = req;
}
var autoSubmit = false; var autoSubmit = false;
var currentUrl = this.icinga.utils.parseUrl(req.$target.data('icingaUrl')); var currentUrl = this.icinga.utils.parseUrl(req.$target.data('icingaUrl'));
if (referrer.method === 'POST') { if (req.method === 'POST') {
var newUrl = this.icinga.utils.parseUrl(req.url); var newUrl = this.icinga.utils.parseUrl(req.url);
if (newUrl.path === currentUrl.path && this.icinga.utils.arraysEqual(newUrl.params, currentUrl.params)) { if (newUrl.path === currentUrl.path && this.icinga.utils.arraysEqual(newUrl.params, currentUrl.params)) {
autoSubmit = true; autoSubmit = true;
@ -816,7 +812,7 @@
let url = currentUrl.path + (locationQuery ? '?' + locationQuery : ''); let url = currentUrl.path + (locationQuery ? '?' + locationQuery : '');
if (req.autosubmit || autoSubmit) { if (req.autosubmit || autoSubmit) {
// Also update a form's action if it doesn't differ from the container's url // Also update a form's action if it doesn't differ from the container's url
var $form = $(referrer.forceFocus).closest('form'); var $form = $(req.forceFocus).closest('form');
var formAction = $form.attr('action'); var formAction = $form.attr('action');
if (!! formAction) { if (!! formAction) {
formAction = this.icinga.utils.parseUrl(formAction); formAction = this.icinga.utils.parseUrl(formAction);
@ -961,7 +957,7 @@
}); });
} }
if (this.processRedirectHeader(req)) { if ((textStatus === 'abort' && typeof req.referrer !== 'undefined') || this.processRedirectHeader(req)) {
return; return;
} }