The following commit has been merged in the master branch:
commit 4456ccc642b7773eed55df751c1681eb5a93e75d
Author: James Vega <[email protected]>
Date:   Sun Aug 1 23:34:40 2010 -0400

    bts: Check usertags for validity and allow multiple modifiers per stanza.
    
    Closes: #590930
    Signed-off-by: James Vega <[email protected]>

diff --git a/debian/changelog b/debian/changelog
index efd82dc..b796d5f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,7 +1,10 @@
 devscripts (2.10.66) UNRELEASED; urgency=low
 
   [ James Vega ]
-  * bts: Fix ability to clear all tags on a bug.  (Closes: #539688)
+  * bts:
+    + Fix ability to clear all tags on a bug.  (Closes: #539688)
+    + Detect invalid characters in usertags.  (Closes: #590930)
+    + Allow specifying multiple tag modifiers (+, -, =) in one usertag stanza.
   * rc-alert: Add missing hyphens and correct formatting in the man page.
     Based on a patch by Salvatore Bonaccorso.  (Closes: #589607)
   * checkbashisms: Allow kill & trap XSI-isms unless --posix is given, as per
diff --git a/scripts/bts.pl b/scripts/bts.pl
index ec50de8..a6ee622 100755
--- a/scripts/bts.pl
+++ b/scripts/bts.pl
@@ -1658,25 +1658,49 @@ sub bts_usertags {
        die "bts usertags: set what user tag?\n";
     }
     # Parse the rest of the command line.
-    my $command="usertags $bug";
-    my $flag="";
-    if ($_[0] =~ /^[-+=]$/) {
-       $flag = $_[0];
-       $command .= " $flag";
-       shift;
-    }
-    elsif ($_[0] =~ s/^([-+=])//) {
-       $flag = $1;
-       $command .= " $flag";
+    my $base_command="usertags $bug";
+    my $commands = [];
+
+    my $curop;
+    foreach my $tag (@_) {
+       if ($tag =~ s/^([-+=])//) {
+           my $op = $1;
+           if ($op eq '=') {
+               $curop = '=';
+               $commands = [];
+           }
+           elsif (!$curop || $curop ne $op) {
+               $curop = $op;
+           }
+           next unless $tag;
+       }
+       if (!$curop) {
+           $curop = '+';
+       }
+       if (!...@$commands || $curop ne $commands->[-1]{op}) {
+           push(@$commands, { op => $curop, tags => [] });
+       }
+       if ($tag !~ m/^[-[:alnum:]...@.+]+$/i) {
+           die "bts usertag: \"$tag\" contains characters other than " .
+               "alpha-numerics, '\@', '.', '+', and '-'.\n";
+       }
+       push(@{$commands->[-1]{tags}}, $tag);
     }
 
-    if ($flag ne '=' && ! @_) {
-       die "bts usertags: set what tag?\n";
+    my $command = '';
+    foreach my $cmd (@$commands) {
+       if ($cmd->{op} ne '=' && !...@{$cmd->{tags}}) {
+           die "bts usertags: set what tag?\n";
+       }
+       $command .= " $cmd->{op} " . join(' ', @{$cmd->{tags}});
+    }
+    if (!$command && $curop eq '=') {
+       $command = " $curop";
     }
-    
-    $command .= " " . join(" ", @_);
 
-    mailbts("usertagging $bug", $command);
+    if ($command) {
+       mailbts("usertagging $bug", $base_command . $command);
+    }
 }
 
 =item claim <bug> [<claim>]

-- 
Git repository for devscripts


-- 
To unsubscribe, send mail to [email protected].

Reply via email to