Permalink
Browse files

fix(parser): throw on unterminated quote instead of infinite loop

  • Loading branch information...
fkleuver committed Oct 30, 2018
1 parent 3923e18 commit 4907f3854db49c4fae0cad9bc8d8ae192c1298d5
Showing with 18 additions and 1 deletion.
  1. +1 −1 src/parser.js
  2. +17 −0 test/parser.spec.js
@@ -472,7 +472,7 @@ export class ParserImplementation {
buffer.push(fromCharCode(unescaped));
marker = this.idx;
} else if (this.ch === /*EOF*/0) {
} else if (this.ch === /*EOF*/0 || this.idx >= this.len) {
this.err('Unterminated quote');
} else {
this.next();
@@ -661,6 +661,23 @@ describe('Parser', () => {
});
describe('should not parse', () => {
describe('LiteralString with unterminated quote', () => {
const expressions = [
'\'a',
'\'',
'a\'',
'"a',
'"',
'a"'
];
for (const expr of expressions) {
it(expr, () => {
_verifyError(expr, 'Unterminated quote');
});
}
});
describe('LiteralObject with computed property', () => {
const expressions = [
'{ []: "foo" }',

0 comments on commit 4907f38

Please sign in to comment.