Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] get_bang_url: handle ambiguous !!bangs without error #740

Merged
merged 3 commits into from Jan 12, 2022

Conversation

return42
Copy link
Member

@return42 return42 commented Jan 11, 2022

What does this PR do?

[fix] get_bang_url: handle ambiguous !!bangs without error

Why is this change important?

An ambiguous bang like !!d raises an exception in function get_bang_url(). A
bang is only unique when the bang_definition from get_bang_definition_and_ac() is
a string / for a ambiguous bang the returned bang_definition is a dictionary.

How to test this PR locally?

make run

Search for !!d foo

Related issues

Reported-by: user @prg318 at #searxng:matrix.org on 2022/01/11

An ambiguous bang like `!!d` raises an exception in function get_bang_url().  A
bang is only unique when the bang_definition from get_bang_definition_and_ac() is
a string / for a ambiguous bang the returned bang_definition is a dictionary.

Reported-by: user prg at #searxng:matrix.org on 2022/01/11
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
@return42
Copy link
Member Author

This PR need some more work, the initial issue is fixed but there is another issue:

Bangs with a * suffix, e.g. !!d*:

{
    "c":"Online Services",
    "d":"www.joindiaspora.com",
    "r":0,
    "s":"Diaspora*",
    "sc":"Social",
    "t":"d*",
    "u":"https://www.joindiaspora.com/people?utf8=\u2713&q={{{s}}}"
}

will overwrite bangs with the same prefix, e.g. !!d

{
    "c":"Research",
    "d":"www.thefreedictionary.com",
    "r":5478,"s":"The Free Dictionary",
    "sc":"Academic",
    "t":"d",
    "u":"http://www.thefreedictionary.com/{{{s}}}"
}

I assume it is caused by the * default:

t = t.setdefault('*', bang_def_output)

@return42
Copy link
Member Author

@dalf are you active working on #740 (comment) .. if not, I can have a look.

@dalf
Copy link
Member

dalf commented Jan 12, 2022

@dalf are you active working on #740 (comment)

not right now

I can have a look.

👍

return42 added a commit to return42/searxng that referenced this pull request Jan 12, 2022
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] searxng#740 (comment)

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
return42 added a commit to return42/searxng that referenced this pull request Jan 12, 2022
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] searxng#740 (comment)

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
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] searxng#740 (comment)

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Updated external bangs by::

    ./manage pyenv.cmd ./searxng_extra/update/update_external_bangs.py

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
@return42
Copy link
Member Author

@dalf I fixed issue of the optimized digital trie in 7cdd314 / if you have time for a review.

Copy link
Member

@dalf dalf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.
Thank you!

@dalf dalf merged commit 687bdef into searxng:master Jan 12, 2022
@return42 return42 deleted the fix-bang branch January 12, 2022 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants