js-binary-schema-parser
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -47,6 +47,14 @@ "use strict"; | ||
var arr = []; | ||
var lastStreamPos = stream.pos; | ||
while (continueFunc(stream, result, parent)) { | ||
var newParent = {}; | ||
parse(stream, schema, result, newParent); | ||
parse(stream, schema, result, newParent); // cases when whole file is parsed but no termination is there and stream position is not getting updated as well | ||
// it falls into infinite recursion, null check to avoid the same | ||
if (stream.pos === lastStreamPos) { | ||
break; | ||
} | ||
lastStreamPos = stream.pos; | ||
arr.push(newParent); | ||
@@ -53,0 +61,0 @@ } |
@@ -21,3 +21,6 @@ "use strict"; | ||
for (var size = (0, _uint.readByte)()(stream); size !== terminator; size = (0, _uint.readByte)()(stream)) { | ||
// catch corrupted files with no terminator | ||
// size becomes undefined for some case when file is corrupted and terminator is not proper | ||
// null check to avoid recursion | ||
if (!size) break; // catch corrupted files with no terminator | ||
if (stream.pos + size >= streamSize) { | ||
@@ -24,0 +27,0 @@ var availableSize = streamSize - stream.pos; |
{ | ||
"name": "js-binary-schema-parser", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Parse binary files with a schema into nicely readable objects", | ||
@@ -5,0 +5,0 @@ "dependencies": {}, |
@@ -76,2 +76,4 @@ # js Binary Schema Parser | ||
[Wethrift.com][6] | ||
[1]: https://www.producthunt.com/posts/ruffle | ||
@@ -82,1 +84,2 @@ [2]: https://github.com/matt-way/gifuct-js | ||
[5]: https://twitter.com/nickdrewe | ||
[6]: https://wethrift.com |
@@ -36,5 +36,12 @@ export const parse = (stream, schema, result = {}, parent = result) => { | ||
const arr = [] | ||
let lastStreamPos = stream.pos; | ||
while (continueFunc(stream, result, parent)) { | ||
const newParent = {} | ||
parse(stream, schema, result, newParent) | ||
// cases when whole file is parsed but no termination is there and stream position is not getting updated as well | ||
// it falls into infinite recursion, null check to avoid the same | ||
if(stream.pos === lastStreamPos) { | ||
break | ||
} | ||
lastStreamPos = stream.pos | ||
arr.push(newParent) | ||
@@ -41,0 +48,0 @@ } |
@@ -25,2 +25,5 @@ import { conditional, loop } from '../' | ||
) { | ||
// size becomes undefined for some case when file is corrupted and terminator is not proper | ||
// null check to avoid recursion | ||
if(!size) break; | ||
// catch corrupted files with no terminator | ||
@@ -27,0 +30,0 @@ if (stream.pos + size >= streamSize) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3158743
658
84