Repository navigation
Conversation
A DateRange ID such as "toString" or "constructor" resolved to an inherited Object.prototype member when the parser looked for a previous DateRange with the same ID. The DateRange constructor then copied properties from a function, leaving its start date undefined, and mapDateRanges threw on getTime(). Store dateRanges in null-prototype objects in LevelDetails and when merging delta playlist DateRanges, so every ID is an own key regardless of its name.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An
EXT-X-DATERANGEID that is also a name onObject.prototype(toString,constructor,hasOwnProperty,__proto__) makesM3U8Parser.parseLevelPlaylist()throw:LevelDetails.dateRangesis a plain object, solevel.dateRanges[ID]resolves to an inherited member when no earlier Date Range with that ID exists. TheDateRangeconstructor treats that member as the previous Date Range, copies itsundefinedstart date, andmapDateRanges()later callsgetTime()on it. RFC 8216bis §4.4.5.1 only says the ID is a quoted-string, so these are valid IDs.Fix
Store
dateRangesin null-prototype objects:LevelDetailsnow createsObject.create(null).mergeDateRanges()copies the old map intoObject.create(null)as well, so a delta update cannot reintroduce the inherited lookup.Only own keys are visible now, and
Object.keys()/iteration behave as before. This mirrors thevariableListfix in #8190.Tests
Two new unit tests, both failing on master with the
TypeErrorabove and passing with the fix:parses DATERANGE tags whose ID matches an Object.prototype property(tests/unit/loader/m3u8-parser.ts) coverstoString,constructor,hasOwnProperty,__proto__and checksstartTime.merges delta Playlist DateRanges whose IDs match Object.prototype properties(tests/unit/controller/level-helper.ts) covers aCAN-SKIP-DATERANGESupdate that keeps, matches and adds such IDs.Validation on the branch:
Fixes #8188.