From 4c768444876bbdf475b4ebce91b387bae342c3d6 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" Date: Tue, 6 Apr 2010 03:32:52 +0000 Subject: [PATCH] Bug 532350 - "Can't add Debian bug URLs to a bug using "See Also"" [r=LpSolit r=mkanat a=mkanat] git-svn-id: svn://10.0.0.236/branches/BUGZILLA-3_6-BRANCH@260156 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/.bzrrev | 2 +- mozilla/webtools/bugzilla/Bugzilla/Bug.pm | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/mozilla/webtools/bugzilla/.bzrrev b/mozilla/webtools/bugzilla/.bzrrev index 6b45ccc32c4..c986e88a331 100644 --- a/mozilla/webtools/bugzilla/.bzrrev +++ b/mozilla/webtools/bugzilla/.bzrrev @@ -1 +1 @@ -7071 \ No newline at end of file +7072 \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/Bugzilla/Bug.pm b/mozilla/webtools/bugzilla/Bugzilla/Bug.pm index 5696880fa19..6114b0ae449 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Bug.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Bug.pm @@ -2421,6 +2421,27 @@ sub add_see_also { $result = "http://code.google.com/p/" . $project_name . "/issues/detail?id=" . $bug_id; } + # Debian BTS URLs + elsif ($uri->authority =~ /^bugs.debian.org$/i) { + # Debian BTS URLs can look like various things: + # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1234 + # http://bugs.debian.org/1234 + my $bug_id; + if ($uri->path =~ m|^/(\d+)$|) { + $bug_id = $1; + } + elsif ($uri->path =~ /bugreport\.cgi$/) { + $bug_id = $uri->query_param('bug'); + detaint_natural($bug_id); + } + if (!$bug_id) { + ThrowUserError('bug_url_invalid', + { url => $input, reason => 'id' }); + } + # This is the shortest standard URL form for Debian BTS URLs, + # and so we reduce all URLs to this. + $result = "http://bugs.debian.org/" . $bug_id; + } # Bugzilla URLs else { if ($uri->path !~ /show_bug\.cgi$/) {