diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2000-08-10 23:03:34 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-08-10 23:03:34 +0000 |
commit | 6b4ac6611c98278a0d6cf49b8f443a5cf6468a7a (patch) | |
tree | afa01341286ca20a733a8d98d2eedd5bb1ad9f74 /lib/CGI/Cookie.pm | |
parent | de34a54bfab4821fac0ced381d11269fbacc498b (diff) | |
download | perl-6b4ac6611c98278a0d6cf49b8f443a5cf6468a7a.tar.gz |
Update to CGI 2.70, from Lincoln Stein.
p4raw-id: //depot/perl@6580
Diffstat (limited to 'lib/CGI/Cookie.pm')
-rw-r--r-- | lib/CGI/Cookie.pm | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/lib/CGI/Cookie.pm b/lib/CGI/Cookie.pm index 575ae79458..8c5ac1efc6 100644 --- a/lib/CGI/Cookie.pm +++ b/lib/CGI/Cookie.pm @@ -40,17 +40,18 @@ sub raw_fetch { my %results; my($key,$value); - my(@pairs) = split("; ",$raw_cookie); + my(@pairs) = split("; ?",$raw_cookie); foreach (@pairs) { - if (/^([^=]+)=(.*)/) { - $key = $1; - $value = $2; - } - else { - $key = $_; - $value = ''; - } - $results{$key} = $value; + s/\s*(.*?)\s*/$1/; + if (/^([^=]+)=(.*)/) { + $key = $1; + $value = $2; + } + else { + $key = $_; + $value = ''; + } + $results{$key} = $value; } return \%results unless wantarray; return %results; @@ -60,17 +61,18 @@ sub parse { my ($self,$raw_cookie) = @_; my %results; - my(@pairs) = split("; ",$raw_cookie); + my(@pairs) = split("; ?",$raw_cookie); foreach (@pairs) { - my($key,$value) = split("="); - my(@values) = map unescape($_),split('&',$value); - $key = unescape($key); - # Some foreign cookies are not in name=value format, so ignore - # them. - next if !defined($value); - # A bug in Netscape can cause several cookies with same name to - # appear. The FIRST one in HTTP_COOKIE is the most recent version. - $results{$key} ||= $self->new(-name=>$key,-value=>\@values); + s/\s*(.*?)\s*/$1/; + my($key,$value) = split("="); + my(@values) = map unescape($_),split('&',$value); + $key = unescape($key); + # Some foreign cookies are not in name=value format, so ignore + # them. + next if !defined($value); + # A bug in Netscape can cause several cookies with same name to + # appear. The FIRST one in HTTP_COOKIE is the most recent version. + $results{$key} ||= $self->new(-name=>$key,-value=>\@values); } return \%results unless wantarray; return %results; @@ -382,7 +384,7 @@ Get or set the cookie's value. Example: $value = $c->value; @new_value = $c->value(['a','b','c','d']); -B<value()> is context sensitive. In a list context it will return +B<value()> is context sensitive. In an array context it will return the current value of the cookie as an array. In a scalar context it will return the B<first> value of a multivalued cookie. |