diff --git a/libraries/src/MVC/Controller/FormController.php b/libraries/src/MVC/Controller/FormController.php index 27d532a5d00b8..164b5d30ce552 100644 --- a/libraries/src/MVC/Controller/FormController.php +++ b/libraries/src/MVC/Controller/FormController.php @@ -324,12 +324,19 @@ public function cancel($key = null) $this->releaseEditId($context, $recordId); \JFactory::getApplication()->setUserState($context . '.data', null); - $this->setRedirect( - \JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list - . $this->getRedirectToListAppend(), false - ) - ); + $url = 'index.php?option=' . $this->option . '&view=' . $this->view_list + . $this->getRedirectToListAppend(); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + if (!is_null($return) && \JUri::isInternal(base64_decode($return))) + { + $url = base64_decode($return); + } + + // Redirect to the list screen. + $this->setRedirect(\JRoute::_($url, false)); return true; }