diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-10-12 13:58:35 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-10-12 13:58:35 +0200 |
commit | bc22c9a0acb095970e9494cbe8954f0612e05dc0 (patch) | |
tree | 4e3a94b7469f5b2e3eaf946756235730429bf9d4 /application/LinkFilter.php | |
parent | 890afc32f744859d11b97eb26ed5c030af9b4145 (diff) | |
parent | ebd67c6e1b40aebdd3a52285ce9ff9412b2a3038 (diff) | |
download | Shaarli-bc22c9a0acb095970e9494cbe8954f0612e05dc0.tar.gz Shaarli-bc22c9a0acb095970e9494cbe8954f0612e05dc0.tar.zst Shaarli-bc22c9a0acb095970e9494cbe8954f0612e05dc0.zip |
Merge tag 'v0.7.0' of github.com:shaarli/Shaarli into stable
Release v0.7.0
Diffstat (limited to 'application/LinkFilter.php')
-rw-r--r-- | application/LinkFilter.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/application/LinkFilter.php b/application/LinkFilter.php index 3fd803cb..e693b284 100644 --- a/application/LinkFilter.php +++ b/application/LinkFilter.php | |||
@@ -44,7 +44,7 @@ class LinkFilter | |||
44 | * Filter links according to parameters. | 44 | * Filter links according to parameters. |
45 | * | 45 | * |
46 | * @param string $type Type of filter (eg. tags, permalink, etc.). | 46 | * @param string $type Type of filter (eg. tags, permalink, etc.). |
47 | * @param string $request Filter content. | 47 | * @param mixed $request Filter content. |
48 | * @param bool $casesensitive Optional: Perform case sensitive filter if true. | 48 | * @param bool $casesensitive Optional: Perform case sensitive filter if true. |
49 | * @param bool $privateonly Optional: Only returns private links if true. | 49 | * @param bool $privateonly Optional: Only returns private links if true. |
50 | * | 50 | * |
@@ -110,6 +110,8 @@ class LinkFilter | |||
110 | * @param string $smallHash permalink hash. | 110 | * @param string $smallHash permalink hash. |
111 | * | 111 | * |
112 | * @return array $filtered array containing permalink data. | 112 | * @return array $filtered array containing permalink data. |
113 | * | ||
114 | * @throws LinkNotFoundException if the smallhash doesn't match any link. | ||
113 | */ | 115 | */ |
114 | private function filterSmallHash($smallHash) | 116 | private function filterSmallHash($smallHash) |
115 | { | 117 | { |
@@ -121,6 +123,11 @@ class LinkFilter | |||
121 | return $filtered; | 123 | return $filtered; |
122 | } | 124 | } |
123 | } | 125 | } |
126 | |||
127 | if (empty($filtered)) { | ||
128 | throw new LinkNotFoundException(); | ||
129 | } | ||
130 | |||
124 | return $filtered; | 131 | return $filtered; |
125 | } | 132 | } |
126 | 133 | ||
@@ -315,6 +322,11 @@ class LinkFilter | |||
315 | $tagsOut = $casesensitive ? $tags : mb_convert_case($tags, MB_CASE_LOWER, 'UTF-8'); | 322 | $tagsOut = $casesensitive ? $tags : mb_convert_case($tags, MB_CASE_LOWER, 'UTF-8'); |
316 | $tagsOut = str_replace(',', ' ', $tagsOut); | 323 | $tagsOut = str_replace(',', ' ', $tagsOut); |
317 | 324 | ||
318 | return array_filter(explode(' ', trim($tagsOut)), 'strlen'); | 325 | return array_values(array_filter(explode(' ', trim($tagsOut)), 'strlen')); |
319 | } | 326 | } |
320 | } | 327 | } |
328 | |||
329 | class LinkNotFoundException extends Exception | ||
330 | { | ||
331 | protected $message = 'The link you are trying to reach does not exist or has been deleted.'; | ||
332 | } | ||