Bug#582171: bugs.debian.org: Can't set multiple users' usertags during submission
Paul Wise <[email protected]> Sun, 28 Feb 2021 10:53:05 +0800
| Newsgroups | gmane.linux.debian.devel.debbugs |
|---|---|
| Organization | Debian |
| Message-ID | <8f65f3550f61b892644b638634ededa7633563cd.camel__1147.44320032827$1614481047$gmane$org@debian.org> |
Control: tags -1 + patch On Tue, 18 May 2010 22:56:30 +0200 Stefano Rivera wrote: > While Usertags can be set on submission (as described in Bug #327591), > attempting to set tags for different users fails. I have implemented support for this in an MR and attached patches: https://salsa.debian.org/debbugs-team/debbugs/-/merge_requests/7 -- bye, pabs https://wiki.debian.org/PaulWise
0001-Fix-pluralising-the-Tag-Usertag-headers.patch
(text/x-patch, 850 B)
From 8feded3eb11818df22688902ceca65ab31e50d37 Mon Sep 17 00:00:00 2001 From: Paul Wise <[email protected]> Date: Sun, 28 Feb 2021 09:59:52 +0800 Subject: [PATCH 1/2] Fix pluralising the Tag/Usertag headers The match was on the lowercase version header names but the lowercasing happened after the header name match. --- scripts/process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/process b/scripts/process index 265bd58..1f40901 100755 --- a/scripts/process +++ b/scripts/process @@ -234,9 +234,9 @@ for my $phline (@bodylines) my ($fn, $fv) = ($1, $2); $fv =~ s/\s*$//; # pluralize tag/usertag + $fn = lc $fn; $fn = $fn.'s' if $fn =~ /^(?:tag|usertag)$/; print {$debugfh} ">$fn|$fv|\n"; - $fn = lc $fn; if ($fn =~ /^control$/) { push @control_bits,$fv; } else { -- 2.30.1
0002-Add-support-for-setting-usertags-for-multiple-users-.patch
(text/x-patch, 3.7 KB)
From 6d3840567049f47c2157c7c373fd683aca9bbe9e Mon Sep 17 00:00:00 2001 From: Paul Wise <[email protected]> Date: Sun, 28 Feb 2021 10:40:06 +0800 Subject: [PATCH 2/2] Add support for setting usertags for multiple users in new bugs Store the user/usertags pseudo-headers separately to the others and then later process them after the new bug has been created. Implements: https://bugs.debian.org/582171 --- scripts/process | 63 ++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/scripts/process b/scripts/process index 1f40901..f33ebec 100755 --- a/scripts/process +++ b/scripts/process @@ -220,6 +220,7 @@ if (@bodylines and $bodylines[0] =~ /^-----BEGIN PGP SIGNED/) { #psuedoheaders my %pheader; my @control_bits; +my @usertag_bits; # extract pseudo-headers for my $phline (@bodylines) { @@ -239,9 +240,12 @@ for my $phline (@bodylines) print {$debugfh} ">$fn|$fv|\n"; if ($fn =~ /^control$/) { push @control_bits,$fv; + } elsif ($fn =~ /^(?:user|usertags)$/) { + $fv = lc $fv; + push @usertag_bits, [$fn, $fv]; } else { # Don't lc owner or forwarded - $fv = lc $fv unless $fn =~ /^(?:owner|forwarded|usertags|version|source-version|done)$/; + $fv = lc $fv unless $fn =~ /^(?:owner|forwarded|version|source-version|done)$/; $pheader{$fn} = $fv; } print {$debugfh} ">$fn~$fv<\n"; @@ -696,32 +700,37 @@ if ($ref<0) { # new bug report $data->{msgid} = $header{'message-id'}; writebug($ref, $data); # Deal with usertags - if (exists $pheader{usertags}) { - my $user = $replyto; - $user = $pheader{user} if exists $pheader{user}; - $user =~ s/,.*//; - $user =~ s/^.*<(.*)>.*$/$1/; - $user =~ s/[(].*[)]//; - $user =~ s/^\s*(\S+)\s+.*$/$1/; - if ($user ne '' and Debbugs::User::is_valid_user($user)) { - $pheader{usertags} =~ s/(?:^\s+|\s+$)//g; - my %user_tags; - read_usertags(\%user_tags,$user); - for my $tag (split /[,\s]+/, $pheader{usertags}) { - if ($tag =~ /^[a-zA-Z0-9.+\@-]+/) { - my %bugs_with_tag; - @bugs_with_tag{@{$user_tags{$tag}||[]}} = (1) x @{$user_tags{$tag}||[]}; - $bugs_with_tag{$ref} = 1; - $user_tags{$tag} = [keys %bugs_with_tag]; - } - } - write_usertags(\%user_tags,$user); - } - else { - $brokenness .= fill_template('mail/invalid_user', - {user => $user} - ); - } + my $current_user = $replyto; + for my $field (@usertags_bits) { + my ($name, $value) = @$field; + if ($name eq 'user') { + my $user = $value; + $user =~ s/,.*//; + $user =~ s/^.*<(.*)>.*$/$1/; + $user =~ s/[(].*[)]//; + $user =~ s/^\s*(\S+)\s+.*$/$1/; + if ($user ne '' and Debbugs::User::is_valid_user($user)) { + $current_user = $user; + } else { + $brokenness .= fill_template('mail/invalid_user', + {user => $user} + ); + } + } + if ($name eq 'usertags'){ + my %user_tags; + read_usertags(\%user_tags, $current_user); + $value =~ s/(?:^\s+|\s+$)//g; + for my $tag (split /[,\s]+/, $value) { + if ($tag =~ /^[a-zA-Z0-9.+\@-]+/) { + my %bugs_with_tag; + @bugs_with_tag{@{$user_tags{$tag}||[]}} = (1) x @{$user_tags{$tag}||[]}; + $bugs_with_tag{$ref} = 1; + $user_tags{$tag} = [keys %bugs_with_tag]; + } + } + write_usertags(\%user_tags,$current_user); + } } overwritefile("db-h/$hash/$ref.report", map {"$_\n"} @msg); -- 2.30.1
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEYQsotVz8/kXqG1Y7MRa6Xp/6aaMFAmA7BZAACgkQMRa6Xp/6 aaN5cA//duEVy4/j4CbKt0fitWwrGkhXeEq6TNyjwojDniLpNBstG9pfaglORyvW wkP/RQesDBtLKKyimwyVH16+2gYtytNemEm3KCcVW21D/VcjG8HW1BHi/03mdJVe +s7s9QrJbYeNuH2Lq/iqtXi+RV+ZWqGWPloXchb3Oj9hUgM4NseeWRVXFxsCsmvu WZIXaDlsPX36GSfQ10/cmO2vqUAwZw9Hm3C13tL6DMjPQVE8yUdf/LszzzjqJcW9 JBPRZtc0oidEw0D8xtqxuHCcGeCWmj/XNgN3Zm3UT9saCd05/xi9LqEryzJD0Wla 5ClGPUpBGs7OwybyCqOJnvekgOHFxwKyuim0+G0XiNyLHseOjSC/uo1gv757EsHc 8OKn5Bqa6XZ/QHp8Yr0CaCs1asA+gXBTULCyfyFYi0NOFrVbPZ2xRube8c1bieMe jGe+MRY4p+LFWjLvj9H6APXOqzOW91KGc7tvU2g0MgsX1nW/lartUkEz6EiErxr+ hOjmPNK8q1MCIEgJhq+Ie9TX8+GxToB9OnwLUnljjFntBibw9NuEjM+v5atMueKr Fi9cVL11pqQzhM7nyjGKs77TnV5k7DBAjxv+ZKiNo1LC0ADVD0tN4kajLnWE/het du3wo/YJ3SnnMgWQ5myqFi7qy3pOPz0xMKqzlY/hS76O4RdaDYg= =3SLv -----END PGP SIGNATURE-----