Ok, I've commited the following patch.  I wonder how many other CGIs it breaks :)

Index: lib/HTTP/Headers/Util.pm
===================================================================
RCS file: /cvsroot/libwww-perl/lwp5/lib/HTTP/Headers/Util.pm,v
retrieving revision 1.9
diff -u -p -u -r1.9 Util.pm
--- lib/HTTP/Headers/Util.pm    16 Sep 2000 17:59:56 -0000      1.9
+++ lib/HTTP/Headers/Util.pm    24 Jan 2003 05:13:25 -0000
@@ -150,11 +150,12 @@ sub join_header_words
            my $k = shift @cur;
            my $v = shift @cur;
            if (defined $v) {
-               if ($v =~ /^\w+$/) {
-                   $k .= "=$v";
-               } else {
+               if ($v =~ /[\x00-\x20()<>@,;:\\\"\/\[\]?={}\x7F-\xFF]/ || !length($v)) 
+{
                    $v =~ s/([\"\\])/\\$1/g;  # escape " and \
                    $k .= qq(="$v");
+               } else {
+                   # token
+                   $k .= "=$v";
                }
            }
            push(@attr, $k);
Index: t/base/cookies.t
===================================================================
RCS file: /cvsroot/libwww-perl/lwp5/t/base/cookies.t,v
retrieving revision 1.16
diff -u -p -u -r1.16 cookies.t
--- t/base/cookies.t    26 Dec 2002 20:32:23 -0000      1.16
+++ t/base/cookies.t    24 Jan 2003 05:13:25 -0000
@@ -563,8 +563,8 @@ $c = HTTP::Cookies->new;  # clear it
 $c->extract_cookies($res);
 print $c->as_string;
 print "not " unless $c->as_string eq <<'EOT'; print "ok 35\n";
-Set-Cookie3: trip.appServer="1111-0000-x-024"; path="/"; domain=".trip.com"; 
path_spec; discard; version=0
-Set-Cookie3: JSESSIONID="fkumjm7nt1.JS24"; path="/trs"; domain="www.trip.com"; 
path_spec; discard; version=1
+Set-Cookie3: trip.appServer=1111-0000-x-024; path="/"; domain=.trip.com; path_spec; 
+discard; version=0
+Set-Cookie3: JSESSIONID=fkumjm7nt1.JS24; path="/trs"; domain=www.trip.com; path_spec; 
+discard; version=1
 EOT
 
 #-------------------------------------------------------------------
Index: t/base/headers-util.t
===================================================================
RCS file: /cvsroot/libwww-perl/lwp5/t/base/headers-util.t,v
retrieving revision 1.5
diff -u -p -u -r1.5 headers-util.t
--- t/base/headers-util.t       30 Mar 1998 13:09:04 -0000      1.5
+++ t/base/headers-util.t       24 Jan 2003 05:13:25 -0000
@@ -17,7 +17,7 @@ my @s_tests = (
    ['foo=bar,bar=baz'         => 'foo=bar, bar=baz'],
 
    ['text/html; charset=iso-8859-1' =>
-    'text/html; charset="iso-8859-1"'],
+    'text/html; charset=iso-8859-1'],
 
    ['foo="bar"; port="80,81"; discard, bar=baz' =>
     'foo=bar; port="80,81"; discard, bar=baz'],

Reply via email to