@isomp4/parser
Advanced tools
+45
-25
@@ -136,23 +136,7 @@ "use strict"; | ||
| } | ||
| // End box | ||
| if (top.box != null) { | ||
| this.onBoxEnded(header, top.box); | ||
| } | ||
| else { | ||
| this.onBoxEnded(header); | ||
| } | ||
| // Pop box state | ||
| this.boxStack.pop(); | ||
| // Check next box state | ||
| if (this.boxStack.length > 0) { | ||
| const next = this.boxStack[this.boxStack.length - 1]; | ||
| next.offset += header.size; | ||
| if (top.box != null && next.box != null && core_1.BoxContainer.isInstance(next.box)) { | ||
| core_1.BoxContainer.add(next.box, top.box); | ||
| } | ||
| } | ||
| // Trigger parsing of next box | ||
| this.currentBox = null; | ||
| this.popBoxStack(top); | ||
| return needed; | ||
| } | ||
| let headerConsumed = 0; | ||
| if (this.currentBox == null) { | ||
@@ -173,3 +157,4 @@ const header = core_1.BoxHeader.parse(buffer); | ||
| }; | ||
| return headerLength; | ||
| buffer = buffer.slice(headerLength); | ||
| headerConsumed += headerLength; | ||
| } | ||
@@ -183,7 +168,7 @@ const header = this.currentBox.header; | ||
| this.bytesNeeded = box; | ||
| return 0; | ||
| return headerConsumed; | ||
| } | ||
| const consumed = encoding.decodedBytes; | ||
| const decodeConsumed = encoding.decodedBytes; | ||
| // Invoke box decoded event | ||
| const children = this.onBoxDecoded(box, buffer.slice(0, consumed)); | ||
| const children = this.onBoxDecoded(box, buffer.slice(0, decodeConsumed)); | ||
| // Push box onto stack (and record whether to parse children) | ||
@@ -194,3 +179,3 @@ this.boxStack.push({ | ||
| children, | ||
| offset: this.currentBox.headerLength + consumed, | ||
| offset: this.currentBox.headerLength + decodeConsumed, | ||
| }); | ||
@@ -202,3 +187,5 @@ // Trigger parsing of child boxes | ||
| } | ||
| return consumed; | ||
| // Check box stack before returning | ||
| this.checkBoxStack(); | ||
| return headerConsumed + decodeConsumed; | ||
| } | ||
@@ -215,4 +202,37 @@ // No encoding, so reset content boolean | ||
| }); | ||
| return this.processBuffer(buffer); | ||
| return headerConsumed + this.processBuffer(buffer); | ||
| } | ||
| checkBoxStack() { | ||
| if (this.boxStack.length > 0) { | ||
| const top = this.boxStack[this.boxStack.length - 1]; | ||
| if (top.offset >= top.header.size) { | ||
| this.popBoxStack(top); | ||
| } | ||
| } | ||
| } | ||
| popBoxStack(top) { | ||
| do { | ||
| // End box | ||
| if (top.box != null) { | ||
| this.onBoxEnded(top.header, top.box); | ||
| } | ||
| else { | ||
| this.onBoxEnded(top.header); | ||
| } | ||
| // Pop box state | ||
| this.boxStack.pop(); | ||
| // Check next box state | ||
| if (this.boxStack.length <= 0) { | ||
| break; | ||
| } | ||
| const parent = this.boxStack[this.boxStack.length - 1]; | ||
| parent.offset += top.header.size; | ||
| if (top.box != null && parent.box != null && core_1.BoxContainer.isInstance(parent.box)) { | ||
| core_1.BoxContainer.add(parent.box, top.box); | ||
| } | ||
| top = parent; | ||
| } while (top.offset >= top.header.size); | ||
| // Trigger parsing of next box | ||
| this.currentBox = null; | ||
| } | ||
| } | ||
@@ -219,0 +239,0 @@ exports.AbstractMP4Parser = AbstractMP4Parser; |
+2
-0
@@ -58,2 +58,4 @@ import { Buffer } from "buffer"; | ||
| private processBuffer; | ||
| private checkBoxStack; | ||
| private popBoxStack; | ||
| /** | ||
@@ -60,0 +62,0 @@ * Invoked when a new box starts from the source. |
+45
-25
@@ -133,23 +133,7 @@ import { Buffer } from "buffer"; | ||
| } | ||
| // End box | ||
| if (top.box != null) { | ||
| this.onBoxEnded(header, top.box); | ||
| } | ||
| else { | ||
| this.onBoxEnded(header); | ||
| } | ||
| // Pop box state | ||
| this.boxStack.pop(); | ||
| // Check next box state | ||
| if (this.boxStack.length > 0) { | ||
| const next = this.boxStack[this.boxStack.length - 1]; | ||
| next.offset += header.size; | ||
| if (top.box != null && next.box != null && BoxContainer.isInstance(next.box)) { | ||
| BoxContainer.add(next.box, top.box); | ||
| } | ||
| } | ||
| // Trigger parsing of next box | ||
| this.currentBox = null; | ||
| this.popBoxStack(top); | ||
| return needed; | ||
| } | ||
| let headerConsumed = 0; | ||
| if (this.currentBox == null) { | ||
@@ -170,3 +154,4 @@ const header = BoxHeader.parse(buffer); | ||
| }; | ||
| return headerLength; | ||
| buffer = buffer.slice(headerLength); | ||
| headerConsumed += headerLength; | ||
| } | ||
@@ -180,7 +165,7 @@ const header = this.currentBox.header; | ||
| this.bytesNeeded = box; | ||
| return 0; | ||
| return headerConsumed; | ||
| } | ||
| const consumed = encoding.decodedBytes; | ||
| const decodeConsumed = encoding.decodedBytes; | ||
| // Invoke box decoded event | ||
| const children = this.onBoxDecoded(box, buffer.slice(0, consumed)); | ||
| const children = this.onBoxDecoded(box, buffer.slice(0, decodeConsumed)); | ||
| // Push box onto stack (and record whether to parse children) | ||
@@ -191,3 +176,3 @@ this.boxStack.push({ | ||
| children, | ||
| offset: this.currentBox.headerLength + consumed, | ||
| offset: this.currentBox.headerLength + decodeConsumed, | ||
| }); | ||
@@ -199,3 +184,5 @@ // Trigger parsing of child boxes | ||
| } | ||
| return consumed; | ||
| // Check box stack before returning | ||
| this.checkBoxStack(); | ||
| return headerConsumed + decodeConsumed; | ||
| } | ||
@@ -212,4 +199,37 @@ // No encoding, so reset content boolean | ||
| }); | ||
| return this.processBuffer(buffer); | ||
| return headerConsumed + this.processBuffer(buffer); | ||
| } | ||
| checkBoxStack() { | ||
| if (this.boxStack.length > 0) { | ||
| const top = this.boxStack[this.boxStack.length - 1]; | ||
| if (top.offset >= top.header.size) { | ||
| this.popBoxStack(top); | ||
| } | ||
| } | ||
| } | ||
| popBoxStack(top) { | ||
| do { | ||
| // End box | ||
| if (top.box != null) { | ||
| this.onBoxEnded(top.header, top.box); | ||
| } | ||
| else { | ||
| this.onBoxEnded(top.header); | ||
| } | ||
| // Pop box state | ||
| this.boxStack.pop(); | ||
| // Check next box state | ||
| if (this.boxStack.length <= 0) { | ||
| break; | ||
| } | ||
| const parent = this.boxStack[this.boxStack.length - 1]; | ||
| parent.offset += top.header.size; | ||
| if (top.box != null && parent.box != null && BoxContainer.isInstance(parent.box)) { | ||
| BoxContainer.add(parent.box, top.box); | ||
| } | ||
| top = parent; | ||
| } while (top.offset >= top.header.size); | ||
| // Trigger parsing of next box | ||
| this.currentBox = null; | ||
| } | ||
| } | ||
@@ -216,0 +236,0 @@ /** |
+5
-4
| { | ||
| "name": "@isomp4/parser", | ||
| "version": "0.2.3", | ||
| "version": "0.2.4", | ||
| "description": "", | ||
@@ -44,6 +44,7 @@ "keywords": [ | ||
| "dependencies": { | ||
| "@isomp4/core": "^0.2.2" | ||
| "@isomp4/core": "^0.2.4" | ||
| }, | ||
| "devDependencies": { | ||
| "@isomp4/box-moov": "^0.2.3" | ||
| "@isomp4/box-moof": "^0.2.4", | ||
| "@isomp4/box-moov": "^0.2.4" | ||
| }, | ||
@@ -57,3 +58,3 @@ "scripts": { | ||
| }, | ||
| "gitHead": "45014bbf407c56481d518ac9e3580b6f6bc47633" | ||
| "gitHead": "d6e734fdd2a32115e96a983de6932b8bf2e24bb9" | ||
| } |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
42002
3.76%616
7.32%2
100%Updated