Skip to content

Commit 10d3af8

Browse files
committed
[fix] engine: duckduckgo - don't quote query string
The query string send to DDG must not be qouted. The query string was URL-qouted in searxng#4011, but the URL-qouted query string result in unexpected *URL decoded* and other garbish results as reported in searxng#4019 and searxng#4020. To test compare the results of a query like:: !ddg Häuser und Straßen :de !ddg Häuser und Straßen :all !ddg 房屋和街道 :all !ddg 房屋和街道 :zh Closed: - [searxng#4019] searxng#4019 - [searxng#4020] searxng#4020 Related: - [searxng#4011] searxng#4011 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
1 parent 4b57bc3 commit 10d3af8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

searx/engines/duckduckgo.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from typing import TYPE_CHECKING
88
import re
9-
from urllib.parse import urlencode, quote_plus
9+
from urllib.parse import urlencode
1010
import json
1111
import babel
1212
import lxml.html
@@ -263,7 +263,7 @@ def request(query, params):
263263

264264
params['url'] = url
265265
params['method'] = 'POST'
266-
params['data']['q'] = quote_plus(query)
266+
params['data']['q'] = query
267267

268268
# The API is not documented, so we do some reverse engineering and emulate
269269
# what https://html.duckduckgo.com/html does when you press "next Page" link
@@ -381,7 +381,11 @@ def response(resp):
381381
zero_click_info_xpath = '//div[@id="zero_click_abstract"]'
382382
zero_click = extract_text(eval_xpath(doc, zero_click_info_xpath)).strip()
383383

384-
if zero_click and "Your IP address is" not in zero_click and "Your user agent:" not in zero_click:
384+
if zero_click and (
385+
"Your IP address is" not in zero_click
386+
and "Your user agent:" not in zero_click
387+
and "URL Decoded:" not in zero_click
388+
):
385389
current_query = resp.search_params["data"].get("q")
386390

387391
results.append(

0 commit comments

Comments
 (0)