noones-search/searx
Markus Heiser e6308b8167 [fix] hardening against arguments of type None, where str or dict is expected
On a long-running server, the tracebacks below can be found (albeit rarely),
which indicate problems with NoneType where a string or another data type is
expected.

result.img_src::

    File "/usr/local/searxng/searxng-src/searx/templates/simple/result_templates/images.html", line 13, in top-level template code
      <img src="" data-src="{{ image_proxify(result.img_src) }}" alt="{{ result.title|striptags }}">{{- "" -}}
      ^
    File "/usr/local/searxng/searxng-src/searx/webapp.py", line 284, in image_proxify
      if url.startswith('//'):
         ^^^^^^^^^^^^^^
    AttributeError: 'NoneType' object has no attribute 'startswith'

result.content::

    File "/usr/local/searxng/searxng-src/searx/result_types/_base.py", line 105, in _normalize_text_fields
      result.content = WHITESPACE_REGEX.sub(" ", result.content).strip()
                       ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
    TypeError: expected string or bytes-like object, got 'NoneType'

html_to_text, when html_str is a NoneType::

    File "/usr/local/searxng/searxng-src/searx/engines/wikipedia.py", line 190, in response
      title = utils.html_to_text(api_result.get('titles', {}).get('display') or api_result.get('title'))
    File "/usr/local/searxng/searxng-src/searx/utils.py", line 158, in html_to_text
      html_str = html_str.replace('\n', ' ').replace('\r', ' ')
                 ^^^^^^^^^^^^^^^^
    AttributeError: 'NoneType' object has no attribute 'replace'

presearch engine, when json_resp is a NoneType::

    File "/usr/local/searxng/searxng-src/searx/engines/presearch.py", line 221, in response
      results = parse_search_query(json_resp.get('results'))
    File "/usr/local/searxng/searxng-src/searx/engines/presearch.py", line 161, in parse_search_query
      for item in json_results.get('specialSections', {}).get('topStoriesCompact', {}).get('data', []):
                  ^^^^^^^^^^^^^^^^
    AttributeError: 'NoneType' object has no attribute 'get'

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-04-01 11:13:47 +02:00
..
answerers [fix] gettext can't work with f-strings (i10n) 2025-01-29 06:04:09 +01:00
botdetection [fix] plugins: bugfix of tor_check and unit_converter 2025-03-15 10:36:33 +01:00
data [data] update searx.data - update_engine_descriptions.py 2025-03-30 09:54:03 +02:00
enginelib [fix] make data.traits - partial revert of commit 30a8204 2025-03-22 07:52:36 +01:00
engines [fix] hardening against arguments of type None, where str or dict is expected 2025-04-01 11:13:47 +02:00
favicons [refactor] typification of SearXNG (initial) / result items (part 1) 2025-01-28 07:07:08 +01:00
infopage [refactor] typification of SearXNG (initial) / result items (part 1) 2025-01-28 07:07:08 +01:00
metrics [fix] openmetrics: value is None if there's no data 2024-11-25 16:57:03 +01:00
network [refactor] typification of SearXNG (initial) / result items (part 1) 2025-01-28 07:07:08 +01:00
plugins [refactor] migrate plugins from "module" to class SXNGPlugin 2025-03-29 10:16:43 +01:00
result_types [fix] hardening against arguments of type None, where str or dict is expected 2025-04-01 11:13:47 +02:00
search [refactor] typification of SearXNG (initial) / result items (part 1) 2025-01-28 07:07:08 +01:00
static/themes/simple [build] /static 2025-03-27 12:27:37 +01:00
templates/simple [mod] migrate all key-value.html templates to KeyValue type 2025-03-15 10:36:33 +01:00
translations [l10n] update translations from Weblate 2025-03-28 08:51:09 +01:00
__init__.py [refactor] typification of SearXNG (initial) / result items (part 1) 2025-01-28 07:07:08 +01:00
autocomplete.py [feat] add Quark autocomplete support 2025-03-31 14:59:49 +02:00
babel_extract.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
compat.py [mod] Revision of the favicon solution 2024-10-05 08:18:28 +02:00
exceptions.py [fix] engine: duckduckgo - CAPTCHA detection 2024-10-19 14:55:44 +02:00
extended_types.py [refactor] typification of SearXNG (initial) / result items (part 1) 2025-01-28 07:07:08 +01:00
external_bang.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
external_urls.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
flaskfix.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
limiter.py [refactor] typification of SearXNG (initial) / result items (part 1) 2025-01-28 07:07:08 +01:00
limiter.toml [chore] *: fix typos detected by typos-cli 2024-11-24 12:41:57 +01:00
locales.py [refactor] typification of SearXNG (initial) / result items (part 1) 2025-01-28 07:07:08 +01:00
openmetrics.py [fix] openmetrics: value is None if there's no data 2024-11-25 16:57:03 +01:00
preferences.py [refactor] migrate plugins from "module" to class SXNGPlugin 2025-03-29 10:16:43 +01:00
query.py [refactor] unit tests to utilize paramaterized and break down monolithic tests 2024-10-03 13:20:32 +02:00
redisdb.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
redislib.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
results.py [refactor] typification of SearXNG (MainResult) / result items (part 2) 2025-03-15 10:36:33 +01:00
searxng.msg Revert "[l10n ga] trigger weblate.push.translations (another try)" 2025-01-06 17:12:16 +01:00
settings.yml [feat] add Quark autocomplete support 2025-03-31 14:59:49 +02:00
settings_defaults.py [refactor] migrate plugins from "module" to class SXNGPlugin 2025-03-29 10:16:43 +01:00
settings_loader.py [mod] revision of the settings_loader 2024-07-14 18:10:06 +02:00
sqlitedb.py [mod] sqlitedb: access to SQLite databases a little more convenient. 2024-10-05 08:18:28 +02:00
sxng_locales.py [fix] make data.traits - partial revert of commit 30a8204 2025-03-22 07:52:36 +01:00
unixthreadname.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
utils.py [fix] hardening against arguments of type None, where str or dict is expected 2025-04-01 11:13:47 +02:00
version.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
webadapter.py [chore] *: fix typos detected by typos-cli 2024-11-24 12:41:57 +01:00
webapp.py [fix] hardening against arguments of type None, where str or dict is expected 2025-04-01 11:13:47 +02:00
webutils.py [fix] JSON & CSV format return error 500 2025-01-29 05:04:41 +01:00