]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 532350 - "Can't add Debian bug URLs to a bug using "See Also""
authorReed Loden <reed@reedloden.com>
Tue, 6 Apr 2010 03:21:50 +0000 (22:21 -0500)
committerReed Loden <reed@reedloden.com>
Tue, 6 Apr 2010 03:21:50 +0000 (22:21 -0500)
[r=LpSolit r=mkanat a=mkanat]

Bugzilla/Bug.pm

index 5696880fa196f510f22e912c67be8fa97f26114f..6114b0ae4499779bb84cf9e69a56570b8fc6c2ef 100644 (file)
@@ -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$/) {