From 4f4ce3c71bb69e3b55029325901e3d16a8142376 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sun, 21 Mar 2021 10:42:27 -0400 Subject: Remove shortcut validation (#3548) Before, only standard shortcuts were supported. When other shortcuts were configured, they were filtered out. Now, those shortcuts are stored in the configuration and an alert message is displayed to alert the user that he is using non-standard shortcuts. See #3481 --- lib/lib_rss.php | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) (limited to 'lib/lib_rss.php') 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 = '') { -- cgit v1.2.3