diff options
Diffstat (limited to 'application/front/controller/visitor/ShaarliVisitorController.php')
-rw-r--r-- | application/front/controller/visitor/ShaarliVisitorController.php | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/application/front/controller/visitor/ShaarliVisitorController.php b/application/front/controller/visitor/ShaarliVisitorController.php index f17c8ed3..55c075a2 100644 --- a/application/front/controller/visitor/ShaarliVisitorController.php +++ b/application/front/controller/visitor/ShaarliVisitorController.php | |||
@@ -78,16 +78,14 @@ abstract class ShaarliVisitorController | |||
78 | 'footer', | 78 | 'footer', |
79 | ]; | 79 | ]; |
80 | 80 | ||
81 | $parameters = $this->buildPluginParameters($template); | ||
82 | |||
81 | foreach ($common_hooks as $name) { | 83 | foreach ($common_hooks as $name) { |
82 | $pluginData = []; | 84 | $pluginData = []; |
83 | $this->container->pluginManager->executeHooks( | 85 | $this->container->pluginManager->executeHooks( |
84 | 'render_' . $name, | 86 | 'render_' . $name, |
85 | $pluginData, | 87 | $pluginData, |
86 | [ | 88 | $parameters |
87 | 'target' => $template, | ||
88 | 'loggedin' => $this->container->loginManager->isLoggedIn(), | ||
89 | 'basePath' => $this->container->basePath, | ||
90 | ] | ||
91 | ); | 89 | ); |
92 | $this->assignView('plugins_' . $name, $pluginData); | 90 | $this->assignView('plugins_' . $name, $pluginData); |
93 | } | 91 | } |
@@ -95,19 +93,23 @@ abstract class ShaarliVisitorController | |||
95 | 93 | ||
96 | protected function executePageHooks(string $hook, array &$data, string $template = null): void | 94 | protected function executePageHooks(string $hook, array &$data, string $template = null): void |
97 | { | 95 | { |
98 | $params = [ | ||
99 | 'target' => $template, | ||
100 | 'loggedin' => $this->container->loginManager->isLoggedIn(), | ||
101 | 'basePath' => $this->container->basePath, | ||
102 | ]; | ||
103 | |||
104 | $this->container->pluginManager->executeHooks( | 96 | $this->container->pluginManager->executeHooks( |
105 | $hook, | 97 | $hook, |
106 | $data, | 98 | $data, |
107 | $params | 99 | $this->buildPluginParameters($template) |
108 | ); | 100 | ); |
109 | } | 101 | } |
110 | 102 | ||
103 | protected function buildPluginParameters(?string $template): array | ||
104 | { | ||
105 | return [ | ||
106 | 'target' => $template, | ||
107 | 'loggedin' => $this->container->loginManager->isLoggedIn(), | ||
108 | 'basePath' => $this->container->basePath, | ||
109 | 'bookmarkService' => $this->container->bookmarkService | ||
110 | ]; | ||
111 | } | ||
112 | |||
111 | /** | 113 | /** |
112 | * Simple helper which prepend the base path to redirect path. | 114 | * Simple helper which prepend the base path to redirect path. |
113 | * | 115 | * |
@@ -140,6 +142,13 @@ abstract class ShaarliVisitorController | |||
140 | 142 | ||
141 | if (null !== $referer) { | 143 | if (null !== $referer) { |
142 | $currentUrl = parse_url($referer); | 144 | $currentUrl = parse_url($referer); |
145 | // If the referer is not related to Shaarli instance, redirect to default | ||
146 | if (isset($currentUrl['host']) | ||
147 | && strpos(index_url($this->container->environment), $currentUrl['host']) === false | ||
148 | ) { | ||
149 | return $response->withRedirect($defaultPath); | ||
150 | } | ||
151 | |||
143 | parse_str($currentUrl['query'] ?? '', $params); | 152 | parse_str($currentUrl['query'] ?? '', $params); |
144 | $path = $currentUrl['path'] ?? $defaultPath; | 153 | $path = $currentUrl['path'] ?? $defaultPath; |
145 | } else { | 154 | } else { |