Skip to content

Commit

Permalink
rewrite: fix new FB dash parsing (#213)
Browse files Browse the repository at this point in the history
Follow-up to #212, additional fixes to embedded dash manifests:
- better search for end tag
- don't attempt rewrite if end tag not found
- bump to 2.20.5
  • Loading branch information
ikreymer authored Nov 20, 2024
1 parent c82830d commit adc2618
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webrecorder/wabac",
"version": "2.20.4",
"version": "2.20.5",
"main": "index.js",
"type": "module",
"exports": {
Expand Down
12 changes: 10 additions & 2 deletions src/rewrite/dsruleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,16 @@ export function removeRangeAsQuery(url: string) {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function ruleRewriteFBDash(text: string, opts: Record<string, any>) {
const start = text.indexOf("\\u003C?xml");
const end = text.indexOf("\\u003C\\/MPD>", start) + "\\u003C\\/MPD>".length;
const START_TAG = "\\u003C?xml";
const END_TAG = "/MPD>";

const start = text.indexOf(START_TAG);
const end = text.indexOf(END_TAG, start) + END_TAG.length;
// if not found, will be END_TAG.length - 1
if (end < END_TAG.length) {
return text;
}

const rwtext: string = JSON.parse('"' + text.slice(start, end) + '"');

let rw = rewriteDASH(rwtext, opts);
Expand Down

0 comments on commit adc2618

Please sign in to comment.