This project is archived and is in readonly mode.
Routing doesn't work with url that omits 0s such as 127.1, 10.1, 192.168.1
-
John Barker
Adding the private method to ActionController::AbstractRequest
# Expands an ip address specified in short format, e.g: 127.1 becomes 127.0.0.1 def expand_address(address) unless address.nil? then new_address = address.dup (3 - address.count('.')).times { new_address.insert(new_address.rindex('.'), '.0') } return new_address end nil endand using it when returning ip addresses from remote_ip, this problem was resolved. Tested with 127.1, 127.0.1, 127.1.1.
-
Bob Aman
- Tag set to url
-1
The method that etw supplied accepts inputs that it probably shouldn't ("127.", "127.1.", etc). And I'm not sure that supporting this is actually a good idea. It could be very confusing to have half of the formats supported by inet_aton() allowed within the routing system, but not the rest. Browsers generally don't support these formats, and it just seems like more work than it's worth to accept "2130706433" as a valid way of saying "127.0.0.1".
Plus, as far as I know, even though inet_aton() generally accepts this form, most (all?) implementations of inet_pton() do not, and no RFC exists that says a URI's host component should be specified this way.
From RFC 3986, Section 3.2.2
The host subcomponent of authority is identified by an IP literal encapsulated within square brackets, an IPv4 address in dotted-decimal form, or a registered name.
IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet dec-octet = DIGIT ; 0-9 / %x31-39 DIGIT ; 10-99 / "1" 2DIGIT ; 100-199 / "2" %x30-34 DIGIT ; 200-249 / "25" %x30-35 ; 250-255 -
Prem Sichanugrist (sikachu)
- State changed from new to wontfix