mirror of
https://github.com/searxng/searxng.git
synced 2025-12-22 19:50:00 +00:00
The JS string, whose encoding will be corrupted if all single quotes (followed by a comma) are replaced with double quotes. Bug was introduced in PR #4573. Here is a simple example in which the list get corrupted:: >>> s = r"""[ 'foo\'', 'bar']""" >>> print(s) [ 'foo\'', 'bar'] >>> print(s.replace("',", "\",")) [ 'foo\'", 'bar'] Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
@@ -807,11 +807,6 @@ def js_variable_to_python(js_variable: str) -> str:
|
||||
s = _JS_DECIMAL_RE.sub(":0.", s)
|
||||
# replace the surogate character by colon
|
||||
s = s.replace(chr(1), ':')
|
||||
# replace single-quote followed by comma with double-quote and comma
|
||||
# {"a": "\"12\"',"b": "13"}
|
||||
# becomes
|
||||
# {"a": "\"12\"","b": "13"}
|
||||
s = s.replace("',", "\",")
|
||||
# load the JSON and return the result
|
||||
return json.loads(s) # pyright: ignore[reportAny]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user