From 6e0cfb7d0fcf1bd757cd2160a5e5a0af13bb00bc Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 26 Jun 2022 18:13:13 +0300 Subject: [PATCH] fix infinite loop in readUnknownSym --- js/csslint/parserlib.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/js/csslint/parserlib.js b/js/csslint/parserlib.js index 6df64f8f..952952ad 100644 --- a/js/csslint/parserlib.js +++ b/js/csslint/parserlib.js @@ -3149,11 +3149,11 @@ self.parserlib = (() => { readUnknownSym() { const reader = this._reader; - const prelude = []; + let prelude = ''; let block; while (true) { - if (reader.eof()) this.throwUnexpected(); - const c = reader.peek(); + let c = reader.peek(); + if (!c) this.throwUnexpected(); if (c === '{') { block = this.readDeclValue({stopOn: ''}); break; @@ -3161,10 +3161,12 @@ self.parserlib = (() => { reader.read(); break; } else { - prelude.push(this.readDeclValue({omitComments: true, stopOn: ';{'})); + c = this.readDeclValue({omitComments: true, stopOn: ';{}'}); + if (!c) break; + prelude += c; } } - return {prelude, block}; + return {prelude: prelude.replace(/^\s+/, ''), block}; } }