diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2022-01-12 18:08:48 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2022-01-12 19:37:13 +0100 |
commit | 7cdd31440e621937550072c3f73e68f644554842 (patch) | |
tree | 621fbc3794b25a8de5803bfe350f662cf9b99f4b /searx/external_bang.py | |
parent | 6d7e86eece852a525ac2ec3c191aca57712ac1a7 (diff) | |
download | searxng-7cdd31440e621937550072c3f73e68f644554842.tar.gz searxng-7cdd31440e621937550072c3f73e68f644554842.zip |
[fix] external bangs: don't overwrite Bangs in data trie
Bangs with a `*` suffix (e.g. `!!d*`) overwrite Bangs with the same
prefix (e.g. `!!d`) [1]. This can be avoid when a non printable character is
used to tag a LEAF_KEY.
[1] https://github.com/searxng/searxng/pull/740#issuecomment-1010411888
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/external_bang.py')
-rw-r--r-- | searx/external_bang.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/searx/external_bang.py b/searx/external_bang.py index ec5a46ed0..a56737c73 100644 --- a/searx/external_bang.py +++ b/searx/external_bang.py @@ -2,6 +2,8 @@ from searx.data import EXTERNAL_BANGS +LEAF_KEY = chr(16) + def get_node(external_bangs_db, bang): node = external_bangs_db['trie'] @@ -26,8 +28,8 @@ def get_bang_definition_and_ac(external_bangs_db, bang): if k.startswith(after): bang_ac_list.append(before + k) elif isinstance(node, dict): - bang_definition = node.get('*') - bang_ac_list = [before + k for k in node.keys() if k != '*'] + bang_definition = node.get(LEAF_KEY) + bang_ac_list = [before + k for k in node.keys() if k != LEAF_KEY] elif isinstance(node, str): bang_definition = node bang_ac_list = [] |