(#4638) cli cookie handling

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

rtcookie.diff (1.73 KB)

Thanks. applied.On Thu, May 06, 2004 at 06:07:39PM -0400, Marc Dougherty wrote:

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

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 () {
    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;
           }
    

Rt-devel mailing list
Rt-devel@lists.bestpractical.com
The rt-devel Archives

At 2004-05-06 18:07:39 -0400, muncus@ccs.neu.edu wrote:

Attached is a patch that solves the problem with cookie handling in
the RT CLI.

What is the problem with cookie handling in the CLI? I’m afraid I do not
understand what your patch is meant to accomplish (perhaps I have missed
some discussion about this?).

  • my $r = submit(“$REST/search/$type”, { query => $q, %data, orderby => $orderby || “” });
  • my $r = submit(“$REST/search/$type”, { query => $q, %data, orderby => $data{orderby} || “” });

The correct fix for this is the one I sent to rt-bugs@ on 2003-12-29, in
20031229082831.A4759@lustre.dyn.wiw.org. Jesse, do you want me to send
a new version of that patch?

– ams

At 2004-05-07 08:23:51 +0530, ams@wiw.org wrote:

The correct fix for this is the one I sent to rt-bugs@ on 2003-12-29,
in 20031229082831.A4759@lustre.dyn.wiw.org.

Not quite. The code has drifted a bit since then.
How about something like the appended patch instead?

– ams

Index: bin/rt.in
— bin/rt.in (revision 851)
+++ bin/rt.in (working copy)
@@ -195,10 +195,12 @@

sub list {
my ($q, $type, %data);

  • $orderby = $config{orderby};
    my $bad = 0;
  • if ($config{orderby}) {
  •    $data{orderby} = $config{orderby};
    
  • }
    while (@ARGV) {
    $_ = shift @ARGV;

@@ -231,9 +233,8 @@
}
}

  • if (!defined $q)
  • {
  •    $q = $config{query} ; 
    
  • if (!defined $q) {

  •    $q = $config{query}; 
    

    }

    $type ||= “ticket”;
    @@ -244,7 +245,7 @@
    }
    return help(“list”, $type) if $bad;

  • my $r = submit(“$REST/search/$type”, { query => $q, %data, orderby => $data{orderby} || “” });
  • my $r = submit(“$REST/search/$type”, { query => $q, %data });
    print $r->content;
    }

At 2004-05-06 18:07:39 -0400, muncus@ccs.neu.edu wrote:

Attached is a patch that solves the problem with cookie handling in
the RT CLI.

What is the problem with cookie handling in the CLI? I’m afraid I do not
understand what your patch is meant to accomplish (perhaps I have missed
some discussion about this?).

we want to match all RT_SID_* cookies, since some sites demanded the
right to change the name of their cookies.

The correct fix for this is the one I sent to rt-bugs@ on 2003-12-29, in
20031229082831.A4759@lustre.dyn.wiw.org. Jesse, do you want me to send
a new version of that patch?

That’s the patch you just sent under seperate cover? I’ll apply when I’m
awake.

At 2004-05-07 08:23:51 +0530, ams@wiw.org wrote:

The correct fix for this is the one I sent to rt-bugs@ on 2003-12-29,
in 20031229082831.A4759@lustre.dyn.wiw.org.

Not quite. The code has drifted a bit since then.
How about something like the appended patch instead?

This patch seems to miss:

     elsif (/^-o$/) {
  •        $orderby = shift @ARGV;
    
  •        $data{'orderby'} = shift @ARGV;
       }
    

I’ve applied this patch with the addition above. Was that the right
thing?

At 2004-05-10 18:57:58 -0400, jesse@bestpractical.com wrote:

     elsif (/^-o$/) {
  •        $orderby = shift @ARGV;
    
  •        $data{'orderby'} = shift @ARGV;
       }
    

Oops, yes, that’s correct.
Thank you.

– ams