[Rt-devel] [PATCH] (#4638) cli cookie handling

Marc Dougherty muncus at ccs.neu.edu
Thu May 6 18:07:39 EDT 2004


Attached is a patch that solves the problem with cookie handling in the
RT CLI. I've tested the patch in both 3.0.10 and the 3.1 branch from
subversion.

According to Netscape's cookie specs, the only characters that are
invalid in a cookie header are semicolon, comma, and whitespace.

The patch also includes the two small fixes noted earlier by darren.

comments welcome.

--Marc.

-- 
Marc "Muncus" Dougherty
Northeastern University
College of Computer and Information Science
-------------- next part --------------
Index: rt.in
===================================================================
--- rt.in	(revision 846)
+++ rt.in	(working copy)
@@ -148,8 +148,9 @@
             my $title = $item->[2]{Title};
             my @titles = ref $title eq 'ARRAY' ? @$title : $title;
 
-        foreach $title (grep $_, @titles) {
-            $help{$title} = $item->[2]{Text};
+            foreach $title (grep $_, @titles) {
+                $help{$title} = $item->[2]{Text};
+            }
         }
     }
 
@@ -234,7 +235,7 @@
     }
     return help("list", $type) if $bad;
 
-    my $r = submit("$REST/search/$type", { query => $q, %data, orderby => $orderby || "" });
+    my $r = submit("$REST/search/$type", { query => $q, %data, orderby => $data{orderby} || "" });
     print $r->content;
 }
 
@@ -838,7 +839,7 @@
     sub cookie {
         my ($self) = @_;
         my $cookie = $self->{sids}{$s}{$u};
-        return defined $cookie ? "RT_SID=$cookie" : undef;
+        return defined $cookie ? "RT_SID_$cookie" : undef;
     }
 
     # Deletes the current session cookie.
@@ -861,7 +862,7 @@
         my ($self, $response) = @_;
         my $cookie = $response->header("Set-Cookie");
 
-        if (defined $cookie && $cookie =~ /^RT_SID=([0-9A-Fa-f]+);/) {
+        if (defined $cookie && $cookie =~ /^RT_SID_(.[^;,\s]+=[0-9A-Fa-f]+);/) {
             $self->{sids}{$s}{$u} = $1;
         }
     }
@@ -878,7 +879,7 @@
             while (<F>) {
                 chomp;
                 next if /^$/ || /^#/;
-                next unless m#^https?://[^ ]+ \w+ [0-9A-Fa-f]+$#;
+                next unless m#^https?://[^ ]+ \w+ [^;,\s]+=[0-9A-Fa-f]+$#;
                 my ($server, $user, $cookie) = split / /, $_;
                 $sids->{$server}{$user} = $cookie;
             }


More information about the Rt-devel mailing list