A feature-rich command-line audio/video downloader
[jsinterp] Improve zeroise (#12313)
sepro4ca8c44a073d
diff --git a/test/test_jsinterp.py b/test/test_jsinterp.pyindex c1464f2cd9..ed3ca61c4b 100644--- a/test/test_jsinterp.py+++ b/test/test_jsinterp.py@@ -93,6 +93,16 @@ class TestJSInterpreter(unittest.TestCase):self._test('function f(){return 0 ?? 42;}', 0)self._test('function f(){return "life, the universe and everything" < 42;}', False)self._test('function f(){return 0 - 7 * - 6;}', 42)+ self._test('function f(){return true << "5";}', 32)+ self._test('function f(){return true << true;}', 2)+ self._test('function f(){return "19" & "21.9";}', 17)+ self._test('function f(){return "19" & false;}', 0)+ self._test('function f(){return "11.0" >> "2.1";}', 2)+ self._test('function f(){return 5 ^ 9;}', 12)+ self._test('function f(){return 0.0 << NaN}', 0)+ self._test('function f(){return null << undefined}', 0)+ # TODO: Does not work due to number too large+ # self._test('function f(){return 21 << 4294967297}', 42)def test_array_access(self):self._test('function f(){var x = [1,2,3]; x[0] = 4; x[0] = 5; x[2.0] = 7; return x;}', [5, 2, 7])diff --git a/test/test_youtube_signature.py b/test/test_youtube_signature.pyindex 13436f0884..7ae627f2c0 100644--- a/test/test_youtube_signature.py+++ b/test/test_youtube_signature.py@@ -201,6 +201,10 @@ _NSIG_TESTS = ['https://www.youtube.com/s/player/2f1832d2/player_ias.vflset/en_US/base.js','YWt1qdbe8SAfkoPHW5d', 'RrRjWQOJmBiP',),+ (+ 'https://www.youtube.com/s/player/9c6dfc4a/player_ias.vflset/en_US/base.js',+ 'jbu7ylIosQHyJyJV', 'uwI0ESiynAmhNg',+ ),]diff --git a/yt_dlp/jsinterp.py b/yt_dlp/jsinterp.pyindex bd6a47004d..ac06297154 100644--- a/yt_dlp/jsinterp.py+++ b/yt_dlp/jsinterp.py@@ -25,7 +25,7 @@ def _js_bit_op(op):with contextlib.suppress(TypeError):if math.isnan(x): # NB: NaN cannot be checked by membershipreturn 0- return x+ return int(float(x))def wrapped(a, b):return op(zeroise(a), zeroise(b)) & 0xffffffff