diff options
Diffstat (limited to 'lib/lib_rss.php')
| -rw-r--r-- | lib/lib_rss.php | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 0181d30de..9521a62c4 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -534,32 +534,17 @@ const SHORTCUT_KEYS = [ 'End', 'Enter', 'Escape', 'Home', 'Insert', 'PageDown', 'PageUp', 'Space', 'Tab', ]; -function validateShortcutList($shortcuts) { - $legacy = array( - 'down' => 'ArrowDown', 'left' => 'ArrowLeft', 'page_down' => 'PageDown', 'page_up' => 'PageUp', - 'right' => 'ArrowRight', 'up' => 'ArrowUp', - ); - $upper = null; - $shortcuts_ok = array(); - - foreach ($shortcuts as $key => $value) { - if ('' === $value) { - $shortcuts_ok[$key] = $value; - } elseif (in_array($value, SHORTCUT_KEYS)) { - $shortcuts_ok[$key] = $value; - } elseif (isset($legacy[$value])) { - $shortcuts_ok[$key] = $legacy[$value]; - } else { //Case-insensitive search - if ($upper === null) { - $upper = array_map('strtoupper', SHORTCUT_KEYS); - } - $i = array_search(strtoupper($value), $upper); - if ($i !== false) { - $shortcuts_ok[$key] = SHORTCUT_KEYS[$i]; - } +function getNonStandardShortcuts($shortcuts) { + $standard = strtolower(implode(' ', SHORTCUT_KEYS)); + + $nonStandard = array_filter($shortcuts, function ($shortcut) use ($standard) { + if (false !== strpos($shortcut, ' ')) { + return true; } - } - return $shortcuts_ok; + return !preg_match("/${shortcut}/i", $standard); + }); + + return $nonStandard; } function errorMessage($errorTitle, $error = '') { |
