This project is archived and is in readonly mode.
redirect_to a custom protocol is causing errors
-
Noah Hendrix
This is Rails 3.0.0.beta4 on ruby 1.9.2dev (2010-05-31 revision 28117) [x86_64-darwin10.4.0]
-
José Valim
- Assigned user set to José Valim
- Importance changed from to Low
Could you please provide a patch with a failing test case in Rails suite? Thanks a lot!
-
Bruno Michel
If you redirect_to a custom protocol, like for to launch an iPhone app, and the URL part starts with a number, it throw an error. If I put a letter after the protocol (e.g. "surveysays://a" + params[:id]) the error goes away and it redirects as expected.
I think it's the expected behaviour: AFAIK, the first URL doesn't respect the RFC 2396, but the second does.
-
Noah Hendrix
From my reading of the RFC it seems that what I wanted to is perfectly allowed. Below I followed the path through to show what options my particular example should fall through to. I surrounded the relevant choices with asterisks. I've never read these kind of documents before so I am possibly missing something, let me know if that is the case.
URI-reference = [ **absoluteURI** | relativeURI ] [ "#" fragment ] --> absoluteURI = scheme ":" ( **hier_part** | opaque_part ) --> hier_part = ( **net_path** | abs_path ) [ "?" query ] --> net_path = "//" **authority** [ abs_path ] --> authority = **server** | reg_name --> server = [ [ userinfo "@" ] **hostport** ] --> hostport = **host** [ ":" port ] --> host = **hostname** | IPv4address --> hostname = *( **domainlabel** "." ) toplabel [ "." ] --> domainlabel = **alphanum** | alphanum *( alphanum | "-" ) alphanum --> alphanum = alpha | **digit** --> digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" -
Bruno Michel
--> hostname = *( domainlabel "." ) toplabel [ "." ]
The trick is on this line. It should be read as: the toplabel is mandatory, but if you want, you can add a domainlabel plus a dot before the toplevel (in fact, you can repeat this operation of adding a domainlabel plus a dot several times).
So, your number should be a toplevel, but it can't as it does not start with an alpha:
toplabel = alpha | alpha *( alphanum | "-" ) alphanum -
Noah Hendrix
Okay, that makes a lot of sense. So, does that mean if I bought a domain like 42.com, it is technically invalid?
-
Bruno Michel
42.com is valid: 42 is a domainlabel in that case, and com, the toplevel, starts by an alpha char.
-
José Valim
- State changed from new to invalid