mirror of
https://github.com/searxng/searxng
synced 2024-11-03 09:40:20 +00:00
Merge pull request #2309 from return42/fix-392
[fix] engine ddg: quote !bangs in a request send to ddg
This commit is contained in:
commit
464e69665c
@ -6,6 +6,7 @@ DuckDuckGo Lite
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
import re
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
import json
|
import json
|
||||||
import babel
|
import babel
|
||||||
@ -15,6 +16,7 @@ from searx import (
|
|||||||
network,
|
network,
|
||||||
locales,
|
locales,
|
||||||
redislib,
|
redislib,
|
||||||
|
external_bang,
|
||||||
)
|
)
|
||||||
from searx import redisdb
|
from searx import redisdb
|
||||||
from searx.utils import (
|
from searx.utils import (
|
||||||
@ -197,6 +199,17 @@ ddg_lang_map = {
|
|||||||
|
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
|
|
||||||
|
# quote ddg bangs
|
||||||
|
query_parts = []
|
||||||
|
# for val in re.split(r'(\s+)', query):
|
||||||
|
for val in re.split(r'(\s+)', query):
|
||||||
|
if not val.strip():
|
||||||
|
continue
|
||||||
|
if val.startswith('!') and external_bang.get_node(external_bang.EXTERNAL_BANGS, val[1:]):
|
||||||
|
val = f"'{val}'"
|
||||||
|
query_parts.append(val)
|
||||||
|
query = ' '.join(query_parts)
|
||||||
|
|
||||||
eng_region = traits.get_region(params['searxng_locale'], traits.all_locale)
|
eng_region = traits.get_region(params['searxng_locale'], traits.all_locale)
|
||||||
# eng_lang = get_ddg_lang(traits, params['searxng_locale'])
|
# eng_lang = get_ddg_lang(traits, params['searxng_locale'])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user