mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-16 01:25:06 +00:00
[utils:js_to_json] Fix bad escape in double quoted strings
This commit is contained in:
parent
63a6494834
commit
d01949dc89
2 changed files with 5 additions and 2 deletions
|
@ -495,6 +495,9 @@ def test_js_to_json_realworld(self):
|
||||||
"playlist":[{"controls":{"all":null}}]
|
"playlist":[{"controls":{"all":null}}]
|
||||||
}''')
|
}''')
|
||||||
|
|
||||||
|
inp = '''"The CW\\'s \\'Crazy Ex-Girlfriend\\'"'''
|
||||||
|
self.assertEqual(js_to_json(inp), '''"The CW's 'Crazy Ex-Girlfriend'"''')
|
||||||
|
|
||||||
inp = '"SAND Number: SAND 2013-7800P\\nPresenter: Tom Russo\\nHabanero Software Training - Xyce Software\\nXyce, Sandia\\u0027s"'
|
inp = '"SAND Number: SAND 2013-7800P\\nPresenter: Tom Russo\\nHabanero Software Training - Xyce Software\\nXyce, Sandia\\u0027s"'
|
||||||
json_code = js_to_json(inp)
|
json_code = js_to_json(inp)
|
||||||
self.assertEqual(json.loads(json_code), json.loads(inp))
|
self.assertEqual(json.loads(json_code), json.loads(inp))
|
||||||
|
|
|
@ -1701,8 +1701,8 @@ def fix_kv(m):
|
||||||
if v in ('true', 'false', 'null'):
|
if v in ('true', 'false', 'null'):
|
||||||
return v
|
return v
|
||||||
if v.startswith('"'):
|
if v.startswith('"'):
|
||||||
return v
|
v = re.sub(r"\\'", "'", v[1:-1])
|
||||||
if v.startswith("'"):
|
elif v.startswith("'"):
|
||||||
v = v[1:-1]
|
v = v[1:-1]
|
||||||
v = re.sub(r"\\\\|\\'|\"", lambda m: {
|
v = re.sub(r"\\\\|\\'|\"", lambda m: {
|
||||||
'\\\\': '\\\\',
|
'\\\\': '\\\\',
|
||||||
|
|
Loading…
Reference in a new issue