summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2017-12-21 03:35:32 +0100
committerGitHub <noreply@github.com>2017-12-21 03:35:32 +0100
commitab88daa3a716f3c972346252fae26e30b113de3e (patch)
treeb74807d55c0b81222622a89c122bccbcec99065e
parent7754ea1c7cab26b5b40e7653f1d6cbe7d246c975 (diff)
downloadbugzilla-ab88daa3a716f3c972346252fae26e30b113de3e.tar.gz
bugzilla-ab88daa3a716f3c972346252fae26e30b113de3e.tar.xz
Bug 1426117 - Failure when opening a bug: Invalid parameter passed to Bugzilla::Bug::new_from_list: It must be numeric.
-rw-r--r--Bugzilla/Template.pm2
-rwxr-xr-xt/bmo/comments.t72
2 files changed, 73 insertions, 1 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index a027614ec..90d9f59f7 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -191,7 +191,7 @@ sub quoteUrls {
}
# Provide tooltips for full bug links (Bug 74355)
- my $urlbase_re = quotemeta(Bugzilla->localconfig->{urlbase});
+ my $urlbase_re = '(' . quotemeta(Bugzilla->localconfig->{urlbase}) . ')';
$text =~ s~\b(${urlbase_re}\Qshow_bug.cgi?id=\E([0-9]+)(\#c([0-9]+))?)\b
~($things[$count++] = $bug_link_func->($3, $1, { comment_num => $5, user => $user })) &&
("\x{FDD2}" . ($count-1) . "\x{FDD3}")
diff --git a/t/bmo/comments.t b/t/bmo/comments.t
new file mode 100755
index 000000000..4b0bb8177
--- /dev/null
+++ b/t/bmo/comments.t
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+use 5.10.1;
+use strict;
+use warnings;
+use lib qw(. lib local/lib/perl5);
+use Test::More;
+
+use Bugzilla;
+use Bugzilla::Constants;
+use Bugzilla::Bug;
+BEGIN { Bugzilla->extensions }
+
+Bugzilla->usage_mode(USAGE_MODE_TEST);
+Bugzilla->error_mode(ERROR_MODE_DIE);
+
+my $user = Bugzilla::User->check({id => 1});
+Bugzilla->set_user($user);
+
+my $bug_1 = Bugzilla::Bug->create(
+ {
+ short_desc => 'A test bug',
+ product => 'Firefox',
+ component => 'General',,
+ bug_severity => 'normal',
+ groups => [],
+ op_sys => 'Unspecified',
+ rep_platform => 'Unspecified',
+ version => 'Trunk',
+ keywords => [],
+ cc => [],
+ comment => 'This is a brand new bug',
+ assigned_to => 'nobody@mozilla.org',
+ }
+);
+ok($bug_1->id, "got a new bug");
+
+my $urlbase = Bugzilla->localconfig->{urlbase};
+my $bug_1_id = $bug_1->id;
+my $bug_2 = Bugzilla::Bug->create(
+ {
+ short_desc => 'A bug that references another bug',
+ product => 'Firefox',
+ component => 'General',,
+ bug_severity => 'normal',
+ groups => [],
+ op_sys => 'Unspecified',
+ rep_platform => 'Unspecified',
+ version => 'Trunk',
+ keywords => [],
+ cc => [],
+ comment => "This is related to ${urlbase}show_bug.cgi?id=$bug_1_id",
+ assigned_to => 'nobody@mozilla.org',
+ }
+);
+
+my $bug_2_id = $bug_2->id;
+
+Bugzilla::Template::quoteUrls(
+ $bug_2->comments->[0]->body, undef, undef, undef,
+ sub {
+ my $bug_id = $_[0];
+ is($bug_id, $bug_1_id, "found Bug $bug_1_id on Bug $bug_2_id");
+ }
+);
+
+done_testing;