diff --git a/lib/Helper/Filter/JSON/FixToolsFilter.php b/lib/Helper/Filter/JSON/FixToolsFilter.php index 6b0c82468..c768cd1bb 100644 --- a/lib/Helper/Filter/JSON/FixToolsFilter.php +++ b/lib/Helper/Filter/JSON/FixToolsFilter.php @@ -55,12 +55,7 @@ public function apply(array &$json): bool { $tools[] = $t; } } else { - $tools = array_map(function ($t) { - $t = trim($t); - $t = $this->textCleaner->cleanUp($t, false); - - return $t; - }, $json[self::TOOLS]); + $tools = $this->processArrayRecursively($json[self::TOOLS]); $tools = array_filter($tools, fn ($t) => ($t)); ksort($tools); $tools = array_values($tools); @@ -71,4 +66,17 @@ public function apply(array &$json): bool { return $changed; } + + private function processArrayRecursively($array) { + return array_map(function ($item) { + if (is_array($item)) { + return $this->processArrayRecursively($item); + } else { + $item = trim($item); + $item = $this->textCleaner->cleanUp($item, false); + return $item; + } + }, $array); + } + } diff --git a/src/js/helper.js b/src/js/helper.js index 1ddf57974..48cd02a6e 100644 --- a/src/js/helper.js +++ b/src/js/helper.js @@ -81,6 +81,9 @@ function isSameItemInstance(url1, url2) { */ function escapeHTML(text) { + if (typeof text !== 'string') { + return text; + } return text.replace( /["&'<>]/g, (a) =>