Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions thrown when someone requests without Host: HTTP header #22

Open
kylev opened this issue Jun 24, 2011 · 2 comments
Open

Exceptions thrown when someone requests without Host: HTTP header #22

kylev opened this issue Jun 24, 2011 · 2 comments

Comments

@kylev
Copy link

kylev commented Jun 24, 2011

http://apidock.com/rails/ActionController/Request/domain

ActionController::Request.domain() will return nil if someone comes to a site using subdomain-fu using only the server's IP address, such as http://10.2.3.4/zomg-haxor.php . In the real world, this sort of thing will happen fairly frequently thanks to security probes, ill-written bots, and crummy HTTP clients. This causes an error, attempting to apply '+' to nil:

gems/subdomain-fu-0.5.4/lib/subdomain-fu.rb:145:in `current_domain'

subdomain-fu should gracefully degrade in some way.

@pboling
Copy link
Collaborator

pboling commented Jun 25, 2011

This is fixed in many of the forks, mine being one example:
https://github.com/pboling/subdomain-fu

It is Rails 3 compatible with a very large test suite. :)

@kylev
Copy link
Author

kylev commented Jun 28, 2011

I might monkey-patch ActionController::Request thusly

def domain_with_default
  domain_without_default || 'example.com'
end
alias_method_chain :domain, :default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants