diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/api/ApiMiddleware.php | 10 | ||||
-rw-r--r-- | application/bookmark/LinkUtils.php | 2 | ||||
-rw-r--r-- | application/front/controller/admin/ManageShaareController.php | 4 |
3 files changed, 11 insertions, 5 deletions
diff --git a/application/api/ApiMiddleware.php b/application/api/ApiMiddleware.php index 09ce6445..f5b53b01 100644 --- a/application/api/ApiMiddleware.php +++ b/application/api/ApiMiddleware.php | |||
@@ -107,7 +107,9 @@ class ApiMiddleware | |||
107 | */ | 107 | */ |
108 | protected function checkToken($request) | 108 | protected function checkToken($request) |
109 | { | 109 | { |
110 | if (! $request->hasHeader('Authorization')) { | 110 | if (!$request->hasHeader('Authorization') |
111 | && !isset($this->container->environment['REDIRECT_HTTP_AUTHORIZATION']) | ||
112 | ) { | ||
111 | throw new ApiAuthorizationException('JWT token not provided'); | 113 | throw new ApiAuthorizationException('JWT token not provided'); |
112 | } | 114 | } |
113 | 115 | ||
@@ -115,7 +117,11 @@ class ApiMiddleware | |||
115 | throw new ApiAuthorizationException('Token secret must be set in Shaarli\'s administration'); | 117 | throw new ApiAuthorizationException('Token secret must be set in Shaarli\'s administration'); |
116 | } | 118 | } |
117 | 119 | ||
118 | $authorization = $request->getHeaderLine('Authorization'); | 120 | if (isset($this->container->environment['REDIRECT_HTTP_AUTHORIZATION'])) { |
121 | $authorization = $this->container->environment['REDIRECT_HTTP_AUTHORIZATION']; | ||
122 | } else { | ||
123 | $authorization = $request->getHeaderLine('Authorization'); | ||
124 | } | ||
119 | 125 | ||
120 | if (! preg_match('/^Bearer (.*)/i', $authorization, $matches)) { | 126 | if (! preg_match('/^Bearer (.*)/i', $authorization, $matches)) { |
121 | throw new ApiAuthorizationException('Invalid JWT header'); | 127 | throw new ApiAuthorizationException('Invalid JWT header'); |
diff --git a/application/bookmark/LinkUtils.php b/application/bookmark/LinkUtils.php index 68914fca..e7af4d55 100644 --- a/application/bookmark/LinkUtils.php +++ b/application/bookmark/LinkUtils.php | |||
@@ -26,7 +26,7 @@ function html_extract_title($html) | |||
26 | */ | 26 | */ |
27 | function header_extract_charset($header) | 27 | function header_extract_charset($header) |
28 | { | 28 | { |
29 | preg_match('/charset="?([^; ]+)/i', $header, $match); | 29 | preg_match('/charset=["\']?([^; "\']+)/i', $header, $match); |
30 | if (! empty($match[1])) { | 30 | if (! empty($match[1])) { |
31 | return strtolower(trim($match[1])); | 31 | return strtolower(trim($match[1])); |
32 | } | 32 | } |
diff --git a/application/front/controller/admin/ManageShaareController.php b/application/front/controller/admin/ManageShaareController.php index ca2da9b5..59ba2de9 100644 --- a/application/front/controller/admin/ManageShaareController.php +++ b/application/front/controller/admin/ManageShaareController.php | |||
@@ -69,7 +69,7 @@ class ManageShaareController extends ShaarliAdminController | |||
69 | $retrieveDescription | 69 | $retrieveDescription |
70 | ) | 70 | ) |
71 | ); | 71 | ); |
72 | if (! empty($title) && strtolower($charset) !== 'utf-8') { | 72 | if (! empty($title) && strtolower($charset) !== 'utf-8' && mb_check_encoding($charset)) { |
73 | $title = mb_convert_encoding($title, 'utf-8', $charset); | 73 | $title = mb_convert_encoding($title, 'utf-8', $charset); |
74 | } | 74 | } |
75 | } | 75 | } |
@@ -127,7 +127,7 @@ class ManageShaareController extends ShaarliAdminController | |||
127 | $this->checkToken($request); | 127 | $this->checkToken($request); |
128 | 128 | ||
129 | // lf_id should only be present if the link exists. | 129 | // lf_id should only be present if the link exists. |
130 | $id = $request->getParam('lf_id') ? intval(escape($request->getParam('lf_id'))) : null; | 130 | $id = $request->getParam('lf_id') !== null ? intval(escape($request->getParam('lf_id'))) : null; |
131 | if (null !== $id && true === $this->container->bookmarkService->exists($id)) { | 131 | if (null !== $id && true === $this->container->bookmarkService->exists($id)) { |
132 | // Edit | 132 | // Edit |
133 | $bookmark = $this->container->bookmarkService->get($id); | 133 | $bookmark = $this->container->bookmarkService->get($id); |