Improved url detection for redirects

This commit is contained in:
Michael 2018-11-30 11:27:17 +00:00
parent 1bd38d1f10
commit 4a1f9a9bdd
2 changed files with 3 additions and 3 deletions

View File

@ -1880,7 +1880,7 @@ class App
*/ */
public function internalRedirect($toUrl = '', $ssl = false) public function internalRedirect($toUrl = '', $ssl = false)
{ {
if (filter_var($toUrl, FILTER_VALIDATE_URL)) { if (!empty(parse_url($toUrl, PHP_URL_SCHEME))) {
throw new InternalServerErrorException("'$toUrl is not a relative path, please use System::externalRedirectTo"); throw new InternalServerErrorException("'$toUrl is not a relative path, please use System::externalRedirectTo");
} }
@ -1897,7 +1897,7 @@ class App
*/ */
public function redirect($toUrl) public function redirect($toUrl)
{ {
if (filter_var($toUrl, FILTER_VALIDATE_URL)) { if (!empty(parse_url($toUrl, PHP_URL_SCHEME))) {
Core\System::externalRedirect($toUrl); Core\System::externalRedirect($toUrl);
} else { } else {
$this->internalRedirect($toUrl); $this->internalRedirect($toUrl);

View File

@ -43,7 +43,7 @@ class Magic extends BaseModule
} }
if (!$cid) { if (!$cid) {
Logger::log('No contact record found: ' . print_r($_REQUEST, true), Logger::DEBUG); Logger::log('No contact record found: ' . json_encode($_REQUEST), Logger::DEBUG);
// @TODO Finding a more elegant possibility to redirect to either internal or external URL // @TODO Finding a more elegant possibility to redirect to either internal or external URL
$a->redirect($dest); $a->redirect($dest);
} }