Closed astj closed 7 years ago
Its worth noting that an RFC based grammar for this is implemented in Grammar::HTTP:
nickl@li685-90:~/perl6$ perl6 -MGrammar::HTTP -e '\
> my $parser = Grammar::HTTP.new;
> my $cookie-string = "Set-Cookie: my-key=my-value";
> say $parser.parse($cookie-string, :rule<set-cookie-header>)
> '
「Set-Cookie: my-key=my-value」
Set-Cookie => 「my-key=my-value」
cookie-pair => 「my-key=my-value」
cookie-name => 「my-key」
cookie-value => 「my-value」
I was womdering that too
It is probable that if it did use HTTP::Grammar then we can close the #142 as well.
In the spirit of agility however I think that I'll fix this without Grammar::HTTP, then attempt to implement that separately.
I've adjusted the token to be somewhat more like the spec (i.e. any non white space character except one of the separators,) and it passes a test based on your example above.
Thanks!
Hi.
I found
HTTP::Cookies
cannot parse some cookies. Here're snippets to reproduce the problem. Cookies having-
in names are not parsed.In current implementation,
HTTP::Cookies::Grammer
definesname
as\w+
. It seems the problem is due to this implementation. According to RFC6265, Cookie name is RFC2616'stoken
. and the RFC definestoken
as follows:In my understand, following characters are accepted as
token
's elements:And those characters seems to be RFC-accepted but
HTTP::Cookie::Grammer
doesn't accept.I don't know
HTTP::Cookies::Grammer
accepts all those characters asname
, but I think it's okay if it accepts some characters like-
.Example
Perl5's
Cookie::Baker
escapesname
on baking cookies when it matchedm![^a-zA-Z\-\._~]!
: https://metacpan.org/source/KAZEBURO/Cookie-Baker-0.07/lib/Cookie/Baker.pm#L36