aboutsummaryrefslogtreecommitdiff
path: root/lib/lib_rss.php
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2021-03-21 10:42:27 -0400
committerGravatar GitHub <noreply@github.com> 2021-03-21 15:42:27 +0100
commit4f4ce3c71bb69e3b55029325901e3d16a8142376 (patch)
tree294999820869f36345034f12e433cad32a4cf74a /lib/lib_rss.php
parente2533bd9468c6d46b991af7b9ad31d67a0a1cc17 (diff)
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
Diffstat (limited to 'lib/lib_rss.php')
-rw-r--r--lib/lib_rss.php35
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 = '') {