mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-28 09:31:01 +01:00
parent
f7f7a877bf
commit
1d7656184c
@ -445,6 +445,16 @@ def test_bitwise_operators_overflow(self):
|
|||||||
jsi = JSInterpreter('function x(){return 1236566549 << 5}')
|
jsi = JSInterpreter('function x(){return 1236566549 << 5}')
|
||||||
self.assertEqual(jsi.call_function('x'), 915423904)
|
self.assertEqual(jsi.call_function('x'), 915423904)
|
||||||
|
|
||||||
|
def test_bitwise_operators_typecast(self):
|
||||||
|
jsi = JSInterpreter('function x(){return null << 5}')
|
||||||
|
self.assertEqual(jsi.call_function('x'), 0)
|
||||||
|
|
||||||
|
jsi = JSInterpreter('function x(){return undefined >> 5}')
|
||||||
|
self.assertEqual(jsi.call_function('x'), 0)
|
||||||
|
|
||||||
|
jsi = JSInterpreter('function x(){return 42 << NaN}')
|
||||||
|
self.assertEqual(jsi.call_function('x'), 42)
|
||||||
|
|
||||||
def test_negative(self):
|
def test_negative(self):
|
||||||
jsi = JSInterpreter("function f(){return 2 * -2.0;}")
|
jsi = JSInterpreter("function f(){return 2 * -2.0;}")
|
||||||
self.assertEqual(jsi.call_function('f'), -4)
|
self.assertEqual(jsi.call_function('f'), -4)
|
||||||
|
@ -146,6 +146,10 @@
|
|||||||
'https://www.youtube.com/s/player/6f20102c/player_ias.vflset/en_US/base.js',
|
'https://www.youtube.com/s/player/6f20102c/player_ias.vflset/en_US/base.js',
|
||||||
'lE8DhoDmKqnmJJ', 'pJTTX6XyJP2BYw',
|
'lE8DhoDmKqnmJJ', 'pJTTX6XyJP2BYw',
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
'https://www.youtube.com/s/player/cfa9e7cb/player_ias.vflset/en_US/base.js',
|
||||||
|
'aCi3iElgd2kq0bxVbQ', 'QX1y8jGb2IbZ0w',
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,12 @@
|
|||||||
|
|
||||||
def _js_bit_op(op):
|
def _js_bit_op(op):
|
||||||
def zeroise(x):
|
def zeroise(x):
|
||||||
return 0 if x in (None, JS_Undefined) else x
|
if x in (None, JS_Undefined):
|
||||||
|
return 0
|
||||||
|
with contextlib.suppress(TypeError):
|
||||||
|
if math.isnan(x): # NB: NaN cannot be checked by membership
|
||||||
|
return 0
|
||||||
|
return x
|
||||||
|
|
||||||
def wrapped(a, b):
|
def wrapped(a, b):
|
||||||
return op(zeroise(a), zeroise(b)) & 0xffffffff
|
return op(zeroise(a), zeroise(b)) & 0xffffffff
|
||||||
|
Loading…
Reference in New Issue
Block a user