Closed Bug 50768 Opened 26 years ago Closed 26 years ago

RFC2109 compliance require ';|,' separated cookies not ' ' separated.

Categories

(Core :: Networking: Cookies, defect, P3)

x86
Linux
defect

Tracking

()

VERIFIED WONTFIX

People

(Reporter: zqex, Assigned: morse)

Details

It would appear that mozilla cookie handling is not compliant to the RFC 2109 (HTTP state management mechanism). Is this by design or by accident? The following excepts are made by using a transparent http session logger between mozilla and apache. First I set a cookie via a small perl cgi script: Request received from client: GET http://localhost/cgibog/setcookie.cgi HTTP/1.1 Host: localhost User-Agent: Mozilla/5.0 (X11; U; Linux 2.2.16-3 i686; en-US; m17) Gecko/20000807 Accept: */* Accept-Language: en, da Accept-Encoding: gzip,deflate,compress,identity Keep-Alive: 300 Connection: keep-alive ----------------------- Reply from server: HTTP/1.1 200 OK Date: Sun, 20 Aug 2000 09:08:51 GMT Server: Apache/1.3.6 (Unix) (Red Hat/Linux) mod_fastcgi/2.2.4 PHP/3.0.7 Set-Cookie: text="newTest"; $Path="/cgibog"; $Domain="localhost" Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html : Now I query the cookie by letting mozilla transfer it to a cgi script in the same domain and path: Request received from client: GET http://localhost/cgibog/readcookie.cgi HTTP/1.1 Cookie: text="newTest" $Path="/cgibog" $Domain="localhost" Host: localhost User-Agent: Mozilla/5.0 (X11; U; Linux 2.2.16-3 i686; en-US; m17) Gecko/20000807 Accept: */* Accept-Language: en, da Accept-Encoding: gzip,deflate,compress,identity Keep-Alive: 300 Connection: keep-alive : The readcookie.cgi script types out the cookie content through $ENV{'HTTP_COOKIE'}. According to RFC2109: Syntax: cookie = "Cookie:" cookie-version 1*((";" | ",") cookie-value) cookie-value = NAME "=" VALUE [";" path] [";" domain] cookie-version = "$Version" "=" value : I.e. a RFC 2109 complaint format would be a version number followed by atleast one member of a ";" or "," separared list as follows: Cookie: $Version="1"; text="newTest"; $Path="/cgibog"; $Domain="localhost" I've tried Netscape 4.73 also space separated cookies. I haven't checket the 'comparable product' from 'another company'. But a webserver from that 'another company' has a very nontolant interpretation of the missing ',' before image/png in the Accept header of Netscape 4.05 and earliere. Which took me quite some time to track. I would rather not see a stupid missing semicolon used the same way by that 'another company'.
Reporter, your Perl script is not sending the cookies properly in the first place. According to RFC 2109, Section 4.2.2 "Set-Cookie Syntax", your Set-Cookie line should be this: Set-Cookie: test="newtest"; Path="/cgibog"; Notice that "Path" is never prefixed with a "$" in the Set-Cookie line. Also, it is explcitly forbidden to use a hostname for the value of "Domain". The Domain must always start with a dot, and contain at least one embedded dot. For example, ".example.com". Don't despair, this is still something of a bug :) According to the RFC: 1) The $Version string is required (only "1" and "0" are defined, and 2) Cookies must be separated by semicolons or commas As a matter of fact, Mozilla's behavior according to the reporter is not even compatible with the Netscape cookie spec, which is superceded by RFC 2109.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: RFC2109 compliance require ';' separated cookies not ' ' separated. → RFC2109 compliance require ';|,' separated cookies not ' ' separated.
Strangely enough, compatibility with either RFC2109 or even with the Netscape Cookie Spec are not a requirement. Both of these specs are flawed and 100% compliance would be impossible (see bug 9422). I haven't read this bug report in detail yet (I intend to) and it might be that this is indeed a useful as well as trivial thing to fix, in which case I'll fix it. But not because it is out of conformance with the spec.
Actually the bug report that I should have cited is 8743 (bug 9422 contains a link to it).
If I'm understanding this bug report, you are complaining about the fact that the cookie header that we generate is Cookie: name=value whereas according to 2109 as well as the Netscape cookie spec it should be Cookie: version=1; name=value I agree that 2109 mentions the version number, but I don't see that in the Netscape cookie spec. That spec states that the syntax is: Cookie: NAME1=OPAQUE_STRING1; NAME2=OPAQUE_STRING2 ... In any event, the header generated by seamonkey is identical to the one generated by 4.x. In that case I wouldn't attempt to change it for fear of breaking some website that isn't expecting a version number. This fix would therefore be consider high risk and not fixing it is zero risk (there is no website that is being broken by the fact that we aren't sending the version number).
Status: NEW → RESOLVED
Closed: 26 years ago
Resolution: --- → WONTFIX
After this bug report, I looked into Moz's cookie handling. As fasr as I can tell, it does the same things that Netscape and IE do, and it plays nicely with Apache. I agree with Morse that the RFC is irrelevant if nobody follows it.
verified
Status: RESOLVED → VERIFIED
(In reply to comment #4) > In any event, the header generated by seamonkey is identical to the one > generated by 4.x. In that case I wouldn't attempt to change it for fear of > breaking some website that isn't expecting a version number. One way to implement RFC2109 and still (likely) be backwards compatible is to return RFC2109-compliant cookies when they were set in an RFC2109-compliant way, i.e. if Version= was specified in the Set-Cookie header. In this way servers will get the old-style cookie unless they are using the RFC2109.
You need to log in before you can comment on or make changes to this bug.