AnyEvent::HTTP and "bad" cookies
Mons Anderson
mons at cpan.org
Sun Jun 20 12:24:55 CEST 2010
On Sun, Jun 20, 2010 at 12:23 PM, José Micó <jose.mico at gmail.com> wrote:
> Just hoping to contribute, I tried to fix to the parser regexp. Then, I
> noted some issues:
>
> 2. Cookies with values "0" are parsed as undef
Oh, really, I forgot to note this issue.
> 3. Google sends cookies with embedded '=', which are wrongly parsed (is this
> valid?)
> 4. As have been said, issues with flags like 'HTTPonly' and friends
>
> In the attached script (near line 70) I made some comments and changes to
> deal with these issues.
> The idea is something like follows, what do you think?
>
>
> --- HTTP.pm
> +++ HTTP.mine.pm
> @@ -595,16 +595,17 @@
>
> # set-cookie processing
> if ($arg{cookie_jar}) {
> + $_[1]{"set-cookie"} =~
> s/(expires\s*=\s*)([^";]*GMT)/$1"$2"/gi; #TODO: review
As for me, I don't like unnecessary additional scan and rewrite of the
whole cookie header.
The mysterious cookie date could be included into the main regexp.
- while (/\G\s* ([^=;,[:space:]]+) \s*=\s*
(?: "((?:[^\\"]+|\\.)*)" | ([^=;,[:space:]]*) )/gcxs) {
+ while (/\G\s* ([^=;,[:space:]]+) (?:
\s*=\s* (?: "((?:[^\\"]+|\\.)*)" |
(A-Z][a-z][a-z],\s\d\d[\s-][A-Z][a-z][a-z][\s-]\d\d(?:\d\d|)\s\d\d:\d\d:\d\d\sGMT|[^;,[:space:]]*)
))?/gcxs) {
--
Best wishes,
Vladimir V. Perepelitsa aka Mons Anderson
<inthrax at gmail.com>, <mons at cpan.org>
More information about the anyevent
mailing list