aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz/Url.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Minz/Url.php')
-rw-r--r--lib/Minz/Url.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Minz/Url.php b/lib/Minz/Url.php
index 0c17e3ec7..2104759cd 100644
--- a/lib/Minz/Url.php
+++ b/lib/Minz/Url.php
@@ -72,7 +72,7 @@ class Minz_Url {
$and = '&';
}
- if (!empty($url['params']['#'])) {
+ if (!empty($url['params']) && is_array($url['params']) && !empty($url['params']['#'])) {
$anchor = '#' . ($encodage === 'html' ? htmlspecialchars($url['params']['#'], ENT_QUOTES, 'UTF-8') : $url['params']['#']);
unset($url['params']['#']);
}
@@ -89,7 +89,7 @@ class Minz_Url {
$separator = $and;
}
- if (isset($url['params'])) {
+ if (isset($url['params']) && is_array($url['params'])) {
unset($url['params']['c']);
unset($url['params']['a']);
foreach ($url['params'] as $key => $param) {
@@ -101,7 +101,7 @@ class Minz_Url {
}
}
- if (!empty($url['#'])) {
+ if (!empty($url['#']) && is_string($url['#'])) {
$uri .= '#' . ($encodage === 'html' ? htmlspecialchars($url['#'], ENT_QUOTES, 'UTF-8') : $url['#']);
}
@@ -141,7 +141,9 @@ class Minz_Url {
*/
public static function unserialize(string $url = ''): array {
try {
- return json_decode(base64_decode($url, true) ?: '', true, JSON_THROW_ON_ERROR) ?? [];
+ $result = json_decode(base64_decode($url, true) ?: '', true, JSON_THROW_ON_ERROR) ?? [];
+ /** @var array{'c'?:string,'a'?:string,'params'?:array<string,mixed>} $result */
+ return $result;
} catch (\Throwable $exception) {
return [];
}