Skip to content

Commit

Permalink
fix(parser): throw on unterminated quote instead of infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
fkleuver committed Oct 30, 2018
1 parent 3923e18 commit 4907f38
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.js
Expand Up @@ -472,7 +472,7 @@ export class ParserImplementation {


buffer.push(fromCharCode(unescaped)); buffer.push(fromCharCode(unescaped));
marker = this.idx; marker = this.idx;
} else if (this.ch === /*EOF*/0) { } else if (this.ch === /*EOF*/0 || this.idx >= this.len) {
this.err('Unterminated quote'); this.err('Unterminated quote');
} else { } else {
this.next(); this.next();
Expand Down
17 changes: 17 additions & 0 deletions test/parser.spec.js
Expand Up @@ -661,6 +661,23 @@ describe('Parser', () => {
}); });


describe('should not parse', () => { 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', () => { describe('LiteralObject with computed property', () => {
const expressions = [ const expressions = [
'{ []: "foo" }', '{ []: "foo" }',
Expand Down

0 comments on commit 4907f38

Please sign in to comment.