mirror of
https://github.com/searxng/searxng
synced 2024-11-18 15:26:25 +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
|
||||
import re
|
||||
from urllib.parse import urlencode
|
||||
import json
|
||||
import babel
|
||||
@ -15,6 +16,7 @@ from searx import (
|
||||
network,
|
||||
locales,
|
||||
redislib,
|
||||
external_bang,
|
||||
)
|
||||
from searx import redisdb
|
||||
from searx.utils import (
|
||||
@ -197,6 +199,17 @@ ddg_lang_map = {
|
||||
|
||||
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_lang = get_ddg_lang(traits, params['searxng_locale'])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user