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

Searchengine Wikipedia causes Internal Error 500 when searching for placenames #1600

Open
djpbessems opened this issue May 23, 2019 · 8 comments

Comments

Projects
None yet
2 participants
@djpbessems
Copy link

commented May 23, 2019

When the searchengine Wikipedia is enabled; I get Internal server errors ("TypeError: encoding without a string argument") when searching for placenames (tested with searchterms 'Amsterdam', 'Singapore', 'Eindhoven' and others).

Disabling Wikipedia completely avoids these errors.

@rachmadaniHaryono

This comment has been minimized.

Copy link
Contributor

commented May 23, 2019

hi @djpbessems, unfortunately i can't reproduce it

can you post error traceback?

based on the error it seem it come from this line

    wikipedia_link = base_url.format(language=url_lang(resp.search_params['language'])) \
        + 'wiki/' + quote(title.replace(' ', '_').encode('utf8'))
@djpbessems

This comment has been minimized.

Copy link
Author

commented May 23, 2019

Sure: https://pastebin.com/2y56HCbd

Thanks for looking into it along with me :)

@rachmadaniHaryono

This comment has been minimized.

Copy link
Contributor

commented May 23, 2019

can you add this to new_hmac function on utils module

    import logging
    logging.debug('secret_key: {!r}\nurl: {!r}'.format(secret_key, url))

on my machine it output following for Singapore search

DEBUG:root:secret_key: 'ultrasecretkey'
url: b'https://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Flag_of_Singapore.svg/300px-Flag_of_Singapore.svg.png'
@djpbessems

This comment has been minimized.

Copy link
Author

commented May 24, 2019

This is my output:

DEBUG:root:secret_key: b'D?0k\xe0%BI\xd6H\xe8\xf8h>\x82\x1d\xb6?)A;\x05\xa4\x94\xce\xa2\xa4\x866\xf5\x7f7'
url: b'https://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Flag_of_Singapore.svg/300px-Flag_of_Singapore.svg.png'
@rachmadaniHaryono

This comment has been minimized.

Copy link
Contributor

commented May 24, 2019

return hmac.new(bytes(secret_key, 'utf-8'), url, hashlib.sha256).hexdigest()
TypeError: encoding without a string argument

looking at error once again and your debug output, it is strange that your secret keys is in bytes instead of string

i will create pr for to handle this case

@rachmadaniHaryono rachmadaniHaryono referenced a pull request that will close this issue May 24, 2019

Open

Feature/fix new hmac #1602

@rachmadaniHaryono

This comment has been minimized.

Copy link
Contributor

commented May 24, 2019

just made the pr. @djpbessems can you check if this is working?

@djpbessems

This comment has been minimized.

Copy link
Author

commented May 25, 2019

I'll try this on monday!

@djpbessems

This comment has been minimized.

Copy link
Author

commented May 27, 2019

I think this issue was actually not caused by searx itself. Sorry for the confusion!

I used https://github.com/siomiz/searx as a base for my own Dockerfile, and also used the file https://code.spamasaurus.com/djpbessems/Docker.Containers.Searx/src/branch/master/config_setup.py; which should generate a random secret_key...
Getting rid of the random created key (os.urandom(32)) actually fixed the whole issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.