diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-11-07 14:57:51 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-11-07 14:57:51 +0000 |
commit | 31e2a2d9bbe3a375912223c133ba793b72600a9f (patch) | |
tree | b19de60c0fa84b86fb9d29b7bca673c37a5fbe54 /actionpack/lib | |
parent | f770b829f4b363888b1af4bc7059bc45637a7ba2 (diff) | |
download | rails-31e2a2d9bbe3a375912223c133ba793b72600a9f.tar.gz rails-31e2a2d9bbe3a375912223c133ba793b72600a9f.tar.bz2 rails-31e2a2d9bbe3a375912223c133ba793b72600a9f.zip |
Fixed handling of non-domain hosts (closes #9479) [purp]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8108 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-x | actionpack/lib/action_controller/request.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index 935e3e08ae..8cfb6d3354 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -191,7 +191,7 @@ module ActionController # Returns the domain part of a host, such as rubyonrails.org in "www.rubyonrails.org". You can specify # a different <tt>tld_length</tt>, such as 2 to catch rubyonrails.co.uk in "www.rubyonrails.co.uk". def domain(tld_length = 1) - return nil if !/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/.match(host).nil? or host.nil? + return nil unless named_host?(host) host.split('.').last(1 + tld_length).join('.') end @@ -200,7 +200,7 @@ module ActionController # You can specify a different <tt>tld_length</tt>, such as 2 to catch ["www"] instead of ["www", "rubyonrails"] # in "www.rubyonrails.co.uk". def subdomains(tld_length = 1) - return [] unless host + return [] unless named_host?(host) parts = host.split('.') parts[0..-(tld_length+2)] end @@ -387,6 +387,10 @@ module ActionController "backtrace" => e.backtrace } end + def named_host?(host) + !(host.nil? || /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.match(host)) + end + class << self def parse_query_parameters(query_string) return {} if query_string.blank? |