From e86c96974d3f6cff74f1a901b44d3eeb0b200b9f Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 28 Aug 2024 20:05:11 +0200 Subject: [fix] self_info: request.user_agent is not a str The user_agent attribute of the Flask request object is an instance of the werkzeug.user_agent.UserAgent class. This will fix the following error of the self_info plugin: > ERROR:searx.plugins.self_info: Exception while calling post_search > Traceback (most recent call last): > File "searx/plugins/__init__.py", line 203, in call > ret = getattr(plugin, plugin_type)(*args, **kwargs) > File "searx/plugins/self_info.py", line 31, in post_search > search.result_container.answers['user-agent'] = {'answer': gettext('Your user-agent is: ') + ua} > TypeError: can only concatenate str (not "UserAgent") to str --- searx/plugins/self_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'searx') diff --git a/searx/plugins/self_info.py b/searx/plugins/self_info.py index b2e714593..7cad040d2 100644 --- a/searx/plugins/self_info.py +++ b/searx/plugins/self_info.py @@ -28,5 +28,5 @@ def post_search(request, search): search.result_container.answers['ip'] = {'answer': gettext('Your IP is: ') + ip} elif ua_regex.match(search.search_query.query): ua = request.user_agent - search.result_container.answers['user-agent'] = {'answer': gettext('Your user-agent is: ') + ua} + search.result_container.answers['user-agent'] = {'answer': gettext('Your user-agent is: ') + ua.string} return True -- cgit v1.2.3-54-g00ecf