From 835234a52c487002a516792dbdea3a44d110ba3d Mon Sep 17 00:00:00 2001 From: Stormwind Date: Sat, 22 Dec 2012 19:08:02 +0100 Subject: Improve query valid regex Now a query string cannot look like 'foo=bar=foo' anymore. --- spec/unit/uri/parse_query_string_spec.rb | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'spec/unit/uri/parse_query_string_spec.rb') diff --git a/spec/unit/uri/parse_query_string_spec.rb b/spec/unit/uri/parse_query_string_spec.rb index a165cf3..3a36cc0 100644 --- a/spec/unit/uri/parse_query_string_spec.rb +++ b/spec/unit/uri/parse_query_string_spec.rb @@ -114,6 +114,32 @@ describe URI, '#parse_query_string' do result.should eq([]) end - # what happend on more than one = without an & or ; in between? + it 'throws an error, if more than one = without an & or ; in between' do + expect { + result = URI::parse_query_string("foo=bar=foo&bar=foo=bar") + }.to raise_error( + ArgumentError, + "invalid data of application/x-www-form-urlencoded "+ + "(foo=bar=foo&bar=foo=bar)" + ) + end + + it 'throws an error, if more than one & without an = in between' do + expect { + result = URI::parse_query_string("foo&bar=foo&bar") + }.to raise_error( + ArgumentError, + "invalid data of application/x-www-form-urlencoded (foo&bar=foo&bar)" + ) + end + + it 'throws an error, if more than one ; without an = in between' do + expect { + result = URI::parse_query_string("foo;bar=foo;bar") + }.to raise_error( + ArgumentError, + "invalid data of application/x-www-form-urlencoded (foo;bar=foo;bar)" + ) + end end -- cgit v1.2.3-70-g09d2