Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9479 (closed defect: fixed)

Opened 1 year ago

Last modified 10 months ago

[PATCH] ActionController::AbstractRequest handles subdomains, domain inconsistently

Reported by: purp Assigned to: core
Priority: normal Milestone: 2.x
Component: ActionPack Version: edge
Severity: normal Keywords:
Cc:

Description

Changeset 2270 introduced dotted-quad handling to ActionController::AbstractRequest#domain without adding it to ActionController::AbstractRequest#subdomains. Additionally, the regex used to match dotted-quad is unanchored, allowing some (admittedly bizarre) edge cases to slip through. For example:

# request.host == '127.0.0.1'
request.domain.nil? # => true
request.subdomains  # => ["127", "0"]

Attached patch (vs. revision 7406) includes tests to demonstrate the defects and refactors both ActionController::AbstractRequest#domain and ActionController::AbstractRequest#subdomains to use a common method for determining whether or not they're dealing with a named host.

Attachments

action_controller_request_treats_dotted_quad_correctly.patch (2.3 kB) - added by purp on 09/05/07 01:35:20.
Tests and code

Change History

09/05/07 01:35:20 changed by purp

  • attachment action_controller_request_treats_dotted_quad_correctly.patch added.

Tests and code

11/07/07 13:06:35 changed by stevenbristol

+1 I get this error in my app.

11/07/07 14:57:54 changed by david

  • status changed from new to closed.
  • resolution set to fixed.

(In [8108]) Fixed handling of non-domain hosts (closes #9479) [purp]