Commits

Michael Granger  committed 2e56a22

Guard against malformed URI query

  • Participants
  • Parent commits ebe06cf

Comments (0)

Files changed (2)

File lib/strelka/httprequest.rb

 	### ?arg1=yes&arg2=no&arg3  #=> {'arg1' => 'yes', 'arg2' => 'no', 'arg3' => nil}
 	def parse_query_args
 		return {} if self.uri.query.nil?
-		return merge_query_args( URI.decode_www_form(self.uri.query) )
+		query_args = begin
+			URI.decode_www_form( self.uri.query )
+		rescue => err
+			self.log.error "%p while parsing query %p: %s" %
+				[ err.class, self.uri.query, err.message ]
+			{}
+		end
+
+		return merge_query_args( query_args )
 	end
 
 

File spec/strelka/httprequest_spec.rb

 					'mirror' => 'sequel',
 				}
 			end
+
+			it "treats a malformed query string as the lack of a query" do
+				req = @request_factory.get( '/directory/path?foo' )
+				req.params.should == {}
+			end
 		end