aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-09-03 18:46:10 +0200
committerArthurHoaro <arthur@hoa.ro>2020-09-03 18:46:10 +0200
commitd33cffdb2e195be118d99342aa42f1d15a186f27 (patch)
treee815df87435ec9c075908d4d94adb45be4b4528d
parent21163a3329ef19dc6ebadb75d6452ac02fd59ab3 (diff)
downloadShaarli-d33cffdb2e195be118d99342aa42f1d15a186f27.tar.gz
Shaarli-d33cffdb2e195be118d99342aa42f1d15a186f27.tar.zst
Shaarli-d33cffdb2e195be118d99342aa42f1d15a186f27.zip
Fix: encoding in legacy route login redirection to post bookmark
When a bookmark is post from a logged out user, he is first redirected to the login page with 'returnurl' containing the link, then redirected again when the login is processed. We need to reencode the posted URL, otherwise the browser does not handle the fragment as a part of the posted parameter.
-rw-r--r--application/legacy/LegacyController.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/application/legacy/LegacyController.php b/application/legacy/LegacyController.php
index e16dd0f4..826604e7 100644
--- a/application/legacy/LegacyController.php
+++ b/application/legacy/LegacyController.php
@@ -39,13 +39,23 @@ class LegacyController extends ShaarliVisitorController
39 /** Legacy route: ?post= */ 39 /** Legacy route: ?post= */
40 public function post(Request $request, Response $response): Response 40 public function post(Request $request, Response $response): Response
41 { 41 {
42 $parameters = count($request->getQueryParams()) > 0 ? '?' . http_build_query($request->getQueryParams()) : '';
43 $route = '/admin/shaare'; 42 $route = '/admin/shaare';
43 $buildParameters = function (?array $parameters, bool $encode) {
44 if ($encode) {
45 $parameters = array_map('urlencode', $parameters);
46 }
47
48 return count($parameters) > 0 ? '?' . http_build_query($parameters) : '';
49 };
50
44 51
45 if (!$this->container->loginManager->isLoggedIn()) { 52 if (!$this->container->loginManager->isLoggedIn()) {
53 $parameters = $buildParameters($request->getQueryParams(), true);
46 return $this->redirect($response, '/login?returnurl='. $this->getBasePath() . $route . $parameters); 54 return $this->redirect($response, '/login?returnurl='. $this->getBasePath() . $route . $parameters);
47 } 55 }
48 56
57 $parameters = $buildParameters($request->getQueryParams(), false);
58
49 return $this->redirect($response, $route . $parameters); 59 return $this->redirect($response, $route . $parameters);
50 } 60 }
51 61