mirror of https://github.com/joomla/joomla-cms.git
[4.4] Fix cancel frontend module editing redirection (#42870)
* Fix redirect URL when cancel editing a module from frontend * Code simplify * More clear comment * Update components/com_config/src/Controller/ModulesController.php Co-authored-by: Brian Teeman <brian@teeman.net> * Fix comment typo * Update components/com_config/src/Controller/ModulesController.php Co-authored-by: Christian Heel <66922325+heelc29@users.noreply.github.com> --------- Co-authored-by: Brian Teeman <brian@teeman.net> Co-authored-by: Quy <quy@nomonkeybiz.com> Co-authored-by: Christian Heel <66922325+heelc29@users.noreply.github.com>
This commit is contained in:
parent
76f6773a9c
commit
3be05bff6a
|
@ -59,8 +59,8 @@ class ModulesController extends BaseController
|
|||
*/
|
||||
public function cancel()
|
||||
{
|
||||
// Redirect back to home(base) page
|
||||
$this->setRedirect(Uri::base());
|
||||
// Redirect back to previous page
|
||||
$this->setRedirect($this->getReturnUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,19 +150,29 @@ class ModulesController extends BaseController
|
|||
|
||||
case 'save':
|
||||
default:
|
||||
if (!empty($returnUri)) {
|
||||
$redirect = base64_decode(urldecode($returnUri));
|
||||
|
||||
// Don't redirect to an external URL.
|
||||
if (!Uri::isInternal($redirect)) {
|
||||
$redirect = Uri::base();
|
||||
}
|
||||
} else {
|
||||
$redirect = Uri::base();
|
||||
}
|
||||
|
||||
$this->setRedirect($redirect);
|
||||
$this->setRedirect($this->getReturnUrl());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get redirect URL after saving or cancel editing a module from frontend
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
private function getReturnUrl(): string
|
||||
{
|
||||
if ($return = $this->input->post->get('return', '', 'BASE64')) {
|
||||
$return = base64_decode(urldecode($return));
|
||||
|
||||
// Only redirect to if it is an internal URL
|
||||
if (Uri::isInternal($return)) {
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
return Uri::base();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue