mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-05-20 20:36:27 +02:00
[utils] js_to_json
: Improve escape handling (#5217)
Authored by: Grub4K
This commit is contained in:
parent
c6989aa3ae
commit
a71b812f53
2 changed files with 39 additions and 26 deletions
|
@ -1100,6 +1100,12 @@ class TestUtil(unittest.TestCase):
|
|||
on = js_to_json('[1,//{},\n2]')
|
||||
self.assertEqual(json.loads(on), [1, 2])
|
||||
|
||||
on = js_to_json(R'"\^\$\#"')
|
||||
self.assertEqual(json.loads(on), R'^$#', msg='Unnecessary escapes should be stripped')
|
||||
|
||||
on = js_to_json('\'"\\""\'')
|
||||
self.assertEqual(json.loads(on), '"""', msg='Unnecessary quote escape should be escaped')
|
||||
|
||||
def test_js_to_json_malformed(self):
|
||||
self.assertEqual(js_to_json('42a1'), '42"a1"')
|
||||
self.assertEqual(js_to_json('42a-1'), '42"a"-1')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue