Skip to content

Commit

Permalink
Update view.js
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Sep 13, 2023
1 parent 38b932f commit f58d22a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions source/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -4816,10 +4816,11 @@ view.ModelContext = class {
switch (type) {
case 'json': {
try {
const buffer = this.stream.peek(Math.min(this.stream.length, 0x1000));
if ((buffer.length < 8 || String.fromCharCode.apply(null, buffer.slice(0, 8)) !== '\x89HDF\r\n\x1A\n') &&
const buffer = stream.peek(Math.min(this.stream.length, 0x1000));
if (stream.length < 0x7ffff000 &&
(buffer.length < 8 || String.fromCharCode.apply(null, buffer.slice(0, 8)) !== '\x89HDF\r\n\x1A\n') &&
(buffer.some((v) => v === 0x22 || v === 0x5b || v === 0x5d || v === 0x7b || v === 0x7d))) {
const reader = json.TextReader.open(this.stream);
const reader = json.TextReader.open(stream);
if (reader) {
const obj = reader.read();
this._content.set(type, obj);
Expand All @@ -4832,7 +4833,7 @@ view.ModelContext = class {
}
case 'json.gz': {
try {
const archive = zip.Archive.open(this.stream, 'gzip');
const archive = zip.Archive.open(stream, 'gzip');
if (archive && archive.entries.size === 1) {
const stream = archive.entries.values().next().value;
const reader = json.TextReader.open(stream);
Expand Down Expand Up @@ -4920,8 +4921,8 @@ view.ModelContext = class {
signatures.some((signature) => signature.length <= stream.length && stream.peek(signature.length).every((value, index) => signature[index] === undefined || signature[index] === value)) ||
(Array.from(this._tags).some((pair) => pair[0] !== 'flatbuffers' && pair[1].size > 0) && type !== 'pb+') ||
Array.from(this._content.values()).some((obj) => obj !== undefined) ||
json.TextReader.open(stream);
if (!skip) {
(stream.length < 0x7ffff000 && json.TextReader.open(stream));
if (!skip && stream.length < 0x7ffff000) {
try {
switch (type) {
case 'pbtxt': {
Expand Down

0 comments on commit f58d22a

Please sign in to comment.