Package: bugs.debian.org Followup-For: Bug #767327 I've prepared a testcase and a patch for the issue.
Please see the attached commits. Regards, Frank -- System Information: Debian Release: 8.3 APT prefers stable APT policy: (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores) Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system)
>From c6904460b23cb1e80987624dca932b959fb4d6b2 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld <[email protected]> Date: Sun, 27 Mar 2016 15:24:15 +0200 Subject: [PATCH 1/2] Extend bugreport test cases to check the output of some control messages This exposes #767327 (wrong package links in "reassigned" message) as a test failure. --- t/07_bugreport.t | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/t/07_bugreport.t b/t/07_bugreport.t index 3600e1c..80dfc92 100644 --- a/t/07_bugreport.t +++ b/t/07_bugreport.t @@ -1,7 +1,7 @@ # -*- mode: cperl;-*- -use Test::More tests => 8; +use Test::More tests => 14; use warnings; use strict; @@ -90,7 +90,44 @@ print STDERR $mech->content(); ok($mech->content() !~ qr/[\x01\x02\x03\x05\x06\x07]/i, 'No unescaped states'); - +# now test the output of some control commands +my @control_commands = + ( + reassign_foo => {command => 'reassign', + value => 'bar', + regex => qr{<strong>bug reassigned from package '<a href="pkgreport\.cgi\?package=foo">foo</a>' to '<a href="pkgreport\.cgi\?package=bar">bar</a>}, + }, + forwarded_foo => {command => 'forwarded', + value => 'https://foo.invalid/bugs?id=1', + regex => qr{<strong>Set bug forwarded-to-address to '<a href="https://foo\.invalid/bugs\?id=1">https://foo\.invalid/bugs\?id=1</a>'\.}, + }, + clone => {command => 'clone', + value => '-1', + regex => qr{<strong>Bug <a href="bugreport.cgi\?bug=1">1</a> cloned as bug <a href="bugreport.cgi\?bug=2">2</a>}, + }, + ); + +while (my ($command,$control_command) = splice(@control_commands,0,2)) { + # just check to see that control doesn't explode + $control_command->{value} = " $control_command->{value}" if length $control_command->{value} + and $control_command->{value} !~ /^\s/; + send_message(to => '[email protected]', + headers => [To => '[email protected]', + From => '[email protected]', + Subject => "Munging a bug with $command", + ], + body => <<EOF) or fail 'message to [email protected] failed'; +debug 10 +$control_command->{command} 1$control_command->{value} +thanks +EOF + ; + # Now test that the output has changed accordingly + $mech->get_ok('http://localhost:'.$port.'/?bug=1', + 'Page received ok'); + like($mech->content(), $control_command->{regex}, + 'Page matches regex'); +} # Other tests for bugs in the page should be added here eventually -- 2.1.4
>From 6176d46de938ccb848b14ed8ca1098313bf7678f Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld <[email protected]> Date: Sun, 27 Mar 2016 15:26:20 +0200 Subject: [PATCH 2/2] Bugreport: Fix problems with reassign message * Matched hardcoded "Bug" instead of $config{bug} (which leads to problems at least in the test suite) * Use package_links() wrong. package_links() already adds HTML. (Closes: #767327) --- Debbugs/CGI/Bugreport.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Debbugs/CGI/Bugreport.pm b/Debbugs/CGI/Bugreport.pm index b1be2ed..8ebbfe8 100644 --- a/Debbugs/CGI/Bugreport.pm +++ b/Debbugs/CGI/Bugreport.pm @@ -395,10 +395,10 @@ sub handle_record{ {$1.$2.(bug_links(bug=>$3)).$4. english_join([map {bug_links(bug=>$_)} (split /\,?\s+(?:and\s+)?/, $5)])}eo; # Add links to reassigned packages - $output =~ s{(Bug\sreassigned\sfrom\spackage\s(?:[\`']|\&\#39;))([^']+?)((?:'|\&\#39;|\"\;) + $output =~ s{($config{bug}\sreassigned\sfrom\spackage\s(?:[\`']|\&\#39;))([^']+?)((?:'|\&\#39;|\"\;) \sto\s(?:[\`']|\&\#39;|\"\;))([^']+?)((?:'|\&\#39;|\"\;))} - {$1.q(<a href=").html_escape(package_links(package=>$2)).qq(">$2</a>).$3. - q(<a href=").html_escape(package_links(package=>$4)).qq(">$4</a>).$5}exo; + {$1.package_links(package=>$2).$3. + package_links(package=>$4).$5}exo; if (defined $time) { $output .= ' ('.strftime('%a, %d %b %Y %T GMT',gmtime($time)).') '; } -- 2.1.4

