diff --git a/lib/parser.js b/lib/parser.js index b9e5e3e..533767e 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -2,7 +2,7 @@ var TOKEN = /([!#\$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+)/, NOTOKEN = /([^!#\$%&'\*\+\-\.\^_`\|~0-9A-Za-z])/g, - QUOTED = /"((?:\\[\x00-\x7f]|[^\x00-\x08\x0a-\x1f\x7f"])*)"/, + QUOTED = /"((?:\\[\x00-\x7f]|[^\x00-\x08\x0a-\x1f\x7f"\\])*)"/, PARAM = new RegExp(TOKEN.source + '(?:=(?:' + TOKEN.source + '|' + QUOTED.source + '))?'), EXT = new RegExp(TOKEN.source + '(?: *; *' + PARAM.source + ')*', 'g'), EXT_LIST = new RegExp('^' + EXT.source + '(?: *, *' + EXT.source + ')*$'), diff --git a/spec/parser_spec.js b/spec/parser_spec.js index 4f85aff..f424648 100644 --- a/spec/parser_spec.js +++ b/spec/parser_spec.js @@ -78,6 +78,11 @@ test.describe("Parser", function() { with(this) { assertEqual( result.params.hasOwnProperty, true ) }}) + it("rejects a string missing its closing quote", function() { with(this) { + assertThrows(SyntaxError, function() { + parse('foo; bar="fooa\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a') + }) + }}) }}) describe("serializeParams", function() { with(this) {