]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/front/controller/visitor/ShaarliVisitorController.php
Fix invalid redirection using the path of an external domain
[github/shaarli/Shaarli.git] / application / front / controller / visitor / ShaarliVisitorController.php
index cd27455bbf8d8810054e469fd564f89804c4c959..55c075a2a87f7ae8c7cad95c5134bf78c53e3cf5 100644 (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 {