2007-05-15 00:08:05 +00:00
|
|
|
require 'cgi'
|
|
|
|
|
2005-01-20 14:55:13 +00:00
|
|
|
class CGI #:nodoc:
|
|
|
|
module QueryExtension
|
2007-01-28 07:16:55 +00:00
|
|
|
# Remove the old initialize_query method before redefining it.
|
|
|
|
remove_method :initialize_query
|
|
|
|
|
2007-05-18 06:24:50 +00:00
|
|
|
# Neuter CGI parameter parsing.
|
2006-06-01 00:01:48 +00:00
|
|
|
def initialize_query
|
|
|
|
# Fix some strange request environments.
|
2007-05-18 06:24:50 +00:00
|
|
|
env_table['REQUEST_METHOD'] ||= 'GET'
|
2005-07-23 09:00:05 +00:00
|
|
|
|
2006-06-01 00:01:48 +00:00
|
|
|
# POST assumes missing Content-Type is application/x-www-form-urlencoded.
|
2007-05-18 06:24:50 +00:00
|
|
|
if env_table['CONTENT_TYPE'].blank? && env_table['REQUEST_METHOD'] == 'POST'
|
|
|
|
env_table['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
|
2005-01-20 14:55:13 +00:00
|
|
|
end
|
2006-06-01 00:01:48 +00:00
|
|
|
|
2007-05-18 06:24:50 +00:00
|
|
|
@cookies = CGI::Cookie::parse(env_table['HTTP_COOKIE'] || env_table['COOKIE'])
|
|
|
|
@params = {}
|
2005-01-20 14:55:13 +00:00
|
|
|
end
|
2007-05-18 06:24:50 +00:00
|
|
|
end
|
2005-01-25 11:15:26 +00:00
|
|
|
end
|