diff --git a/lib/websocket/extensions/parser.rb b/lib/websocket/extensions/parser.rb index d2434df..f8d8891 100644 --- a/lib/websocket/extensions/parser.rb +++ b/lib/websocket/extensions/parser.rb @@ -6,7 +6,7 @@ class Extensions class Parser TOKEN = /([!#\$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+)/ NOTOKEN = /([^!#\$%&'\*\+\-\.\^_`\|~0-9A-Za-z])/ - QUOTED = /"((?:\\[\x00-\x7f]|[^\x00-\x08\x0a-\x1f\x7f"])*)"/ + QUOTED = /"((?:\\[\x00-\x7f]|[^\x00-\x08\x0a-\x1f\x7f"\\])*)"/ PARAM = %r{#{ TOKEN.source }(?:=(?:#{ TOKEN.source }|#{ QUOTED.source }))?} EXT = %r{#{ TOKEN.source }(?: *; *#{ PARAM.source })*} EXT_LIST = %r{^#{ EXT.source }(?: *, *#{ EXT.source })*$} diff --git a/spec/websocket/extensions/parser_spec.rb b/spec/websocket/extensions/parser_spec.rb index ec3a837..7458210 100644 --- a/spec/websocket/extensions/parser_spec.rb +++ b/spec/websocket/extensions/parser_spec.rb @@ -76,6 +76,12 @@ def parse(string) { :name => "a", :params => { "b" => true } } ] end + + it "rejects a string missing its closing quote" do + expect { + 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" + }.to raise_error(WebSocket::Extensions::Parser::ParseError) + end end describe :serialize_params do