Commit Graph

84 Commits (c052a16f72af7dd7671d4dd62826de71cd99dfb6)

Author SHA1 Message Date
dirkf c052a16f72 [JSInterp] Add tests and relevant functionality from yt-dlp
* thx seproDev, bashonly: yt-dlp/yt-dlp#12760, yt-dlp/yt-dlp#12761:
  - Improve nested attribute support
  - Pass global stack when extracting objects
  - interpret_statement: Match attribute before indexing
  - Fix assignment to array elements with nested brackets
  - Add new signature tests
  - Invalidate JS function cache
  - Avoid testdata dupes now that we cache by URL

* rework nsig function name search
* fully fixes #33102
* update cache required versions
* update program version
8 months ago
dirkf bd2ded59f2 [JSInterp] Improve unary operators; add `!` 8 months ago
dirkf 16b7e97afa [JSInterp] Add `_separate_at_op()` 8 months ago
dirkf d21717978c [JSInterp] Improve JS classes, etc 8 months ago
dirkf 7513413794 [JSInterp] Reorganise some declarations to align better with yt-dlp 8 months ago
dirkf 3eb8d22ddb
[JSInterp] Temporary fix for #33102 8 months ago
dirkf 1bc45b8b6c [JSInterp] Use `,` for join() with null/undefined argument
Eg: [1,2,3].join(null) -> '1,2,3'
8 months ago
dirkf c55dbf4838 [YouTube] Update signature extraction for players `643afba4`, `363db69b` 8 months ago
dirkf a4fc1151f1 [JSInterp] Improve indexing
* catch invalid list index with `ValueError` (eg [1, 2]['ab'] -> undefined)
* allow assignment outside existing list (eg var l = [1,2]; l[9] = 0;)
8 months ago
dirkf 420d53387c [JSInterp] Improve tests
* from yt-dlp/yt-dlp#12313
* also fix d7c2708
9 months ago
dirkf 1dc27e1c3b [JSInterp] Make indexing error handling more conformant
* by default TypeError -> undefined, else raise
* set allow_undefined=True/False to override
9 months ago
dirkf af049e309b [JSInterp] Handle undefined, etc, passed to JS_RegExp and Exception 9 months ago
dirkf 94849bc997 [JSInterp] Improve Date processing
* add JS_Date class implementing JS Date
* support constructor args other than date string
* support static methods of Date
* Date objects are still automatically coerced to timestamp before using in JS.
9 months ago
dirkf 711e72c292 [JSInterp] Fix bit-shift coercion for player 9c6dfc4a 10 months ago
dirkf ce1e556b8f [jsinterp] Add return hook for player `3bb1f723`
* set var `_ytdl_do_not_return` to a specific value in the scope of a function
* if an expression to be returned has that value, `return` becomes `void`
12 months ago
dirkf f487b4a02a [jsinterp] Strip /* comments */ when parsing
* NB: _separate() is looking creaky
12 months ago
dirkf 60835ca16c [jsinterp] Fix and improve "methods"
* push, unshift return new length
* impove edge cases for push/pop, shift/unshift, forEach, indexOf, charCodeAt
* increase test coverage
12 months ago
dirkf 94fd774608 [jsinterp] Fix and improve split/join
* improve split/join edge cases
* correctly implement regex split (not like re.split)
12 months ago
dirkf 5dee6213ed [jsinterp] Fix and improve arithmetic operations
* addition becomes concat with a string operand
* improve handling of edgier cases
* arithmetic in float like JS (more places need cast to int?)
* increase test coverage
12 months ago
dirkf 81e64cacf2 [jsinterp] Support multiple indexing (eg a[1][2])
* extend single indexing with improved RE (should probably use/have used _separate_at_paren())
* fix some cases that should have given undefined, not throwing
* standardise RE group names
* support length of objects, like {1: 2, 3: 4, length: 42}
12 months ago
dirkf c1a03b1ac3 [jsinterp] Fix and improve loose and strict equality operations
* reimplement loose equality according to MDN (eg, 1 == "1")
* improve strict equality (eg, "abc" === "abc" but 'abc' is not 'abc')
* add tests for above
12 months ago
dirkf 118c6d7a17 [jsinterp] Implement `typeof` operator 12 months ago
dirkf dbc08fba83 [jsinterp] Improve slice implementation for player b12cc44b
Partly taken from yt-dlp/yt-dlp#10664, thx seproDev
        Fixes #32896
1 year ago
dirkf d35ce6ce95 [jsinterp] Support functionality for player `b22ef6e7`
* support `prototype` for call() and apply() (yt-dlp/yt-dlp#10392, thx Grub4k)
* map JS `Array` to `list`
1 year ago
dirkf 76ac69917e [jsinterp] Further improve expression parsing (fix fd8242e)
Passes tests from yt-dlp
1 year ago
dirkf 756f6b45c7 [jsinterp] Re-align JSInterp and tests (esp.) with yt-dlp
Thx: various yt-dlp authors
1 year ago
dirkf e0094e63c3 [jsinterp] Various tweaks
* treat Infinity like NaN
* cache operator list
1 year ago
dirkf fd8242e3ef [jsinterp] Fix and improve expression parsing
* improve BODMAS (fixes https://github.com/ytdl-org/youtube-dl/issues/32815)
* support more weird expressions with multiple unary ops
1 year ago
dirkf ad01fa6cca [jsinterp] Add Debugger from yt-dlp
* https://github.com/yt-dlp/yt-dlp/commit/8f53dc4
* thx pukkandan
1 year ago
dirkf 1d8d5a93f7 [test] Fixes for old Pythons 2 years ago
dirkf f24bc9272e [Misc] Fixes for 2.6 compatibility 2 years ago
dirkf 07af47960f [YouTube] Improve fix for ae8ba2c
Thx: https://github.com/yt-dlp/yt-dlp/commit/01aba25
2 years ago
dirkf d6433cbb2c [jsinterp] Don't find unrelated objects 3 years ago
dirkf ff75c300f5 [jsinterp] Fix test for failed match in extract_object() 3 years ago
dirkf a2534f7b88 [jsinterp] Fix div bug breaking player 8c7583ff
Thx bashonly: https://github.com/ytdl-org/youtube-dl/issues/32292#issuecomment-1585639223
Fixes #32292
3 years ago
dirkf d89c2137ba [jsinterp] Small updates for a85a875
* update signature tests
* clarify NaN handling
3 years ago
dirkf 6ed3433828 [jsinterp] Add short-cut evaluation for common expression
* special handling for (d%e.length+e.length)%e.length speeds up ~6%
3 years ago
dirkf a85a875fef [jsinterp] Handle NaN in bitwise operators
* also add _NaN
* also pull function naming from yt-dlp
3 years ago
dirkf 211cbfd5d4 [jsinterp] Minimally handle arithmetic operator precedence
Resolves #32066
3 years ago
dirkf 0402710227 [jsinterp] Fix regexp parsing and .replace[All] method
* For performance, make regexp object instantiation lazy
 * Other small performance improvements
3 years ago
pukkandan 3e92c60fcd [jsinterp] Handle `Date` at epoch 0
See yt-dlp/yt_dlp#6400
3 years ago
dirkf 57802e632f [jsinterp] Fix dict comprehension for Py2.6
Resolves #31600
3 years ago
dirkf cd987e6fca [jsinterp] Nits 3 years ago
dirkf 295736c9cb [jsinterp] Improve parsing
* support subset `... else if ...`
* support `while`
* add `RegExp` class
* generalise `new` support
* limited more debug strings
* matching test changes
3 years ago
pukkandan 14ef89a8da Support `if` statements
Fix for yt-dlp/yt_dlp#6131
Closes #31509
3 years ago
dirkf 6e2626f092
[JSInterp] Improve separation logic
Based on 0468a3b325
3 years ago
pukkandan 7009bb9f31 [jsinterp] Workaround operator associativity issue
* temporary fix for player 5a3b6271 [1]

1. https://github.com/yt-dlp/yt-dlp/issues/4635#issuecomment-1235384480
3 years ago
dirkf 55c823634d [jsinterp] Handle new YT players 113ca41c, c57c113c
* add NaN
* allow any white-space character for `after_op`
* align with yt-dlp f26af78a8ac11d9d617ed31ea5282cfaa5bcbcfa (charcodeAt and bitwise overflow)
* allow escaping in regex, fixing player c57c113c
3 years ago
dirkf 4c6fba3765 [jsinterp] Improve try/catch/finally support 3 years ago
dirkf d619dd712f [jsinterp] Fix bug in operator precedence
* from 164b03c486
* added tests
3 years ago