diff options
Diffstat (limited to 'lib/lib_rss.php')
| -rw-r--r-- | lib/lib_rss.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 3e0033a61..fd1389047 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -280,6 +280,9 @@ function customSimplePie($attributes = array()) { } function sanitizeHTML($data, $base = '') { + if (!is_string($data)) { + return ''; + } static $simplePie = null; if ($simplePie == null) { $simplePie = customSimplePie(); @@ -544,3 +547,39 @@ function base64url_decode($data) { function _i($icon, $url_only = false) { return FreshRSS_Themes::icon($icon, $url_only); } + + +const SHORTCUT_KEYS = array( + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', + 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'Backspace', 'Delete', + '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 (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]; + } + } + } + return $shortcuts_ok; +} |
