Fix invalid redirection using the path of an external domain

Fixes 
This commit is contained in:
ArthurHoaro 2020-09-22 15:17:13 +02:00
parent 5baafe5001
commit abe033be85
5 changed files with 54 additions and 16 deletions
application/front/controller/visitor

View file

@ -142,6 +142,13 @@ abstract class ShaarliVisitorController
if (null !== $referer) {
$currentUrl = parse_url($referer);
// If the referer is not related to Shaarli instance, redirect to default
if (isset($currentUrl['host'])
&& strpos(index_url($this->container->environment), $currentUrl['host']) === false
) {
return $response->withRedirect($defaultPath);
}
parse_str($currentUrl['query'] ?? '', $params);
$path = $currentUrl['path'] ?? $defaultPath;
} else {