]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 533121 - "Support Google Code for see_also urls"
authorReed Loden <reed@reedloden.com>
Tue, 30 Mar 2010 01:01:45 +0000 (20:01 -0500)
committerReed Loden <reed@reedloden.com>
Tue, 30 Mar 2010 01:01:45 +0000 (20:01 -0500)
[r=LpSolit a=mkanat]

Bugzilla/Bug.pm

index c7c1681252a8c00f4c1a6553096cd4139de8b211..2ce292edbb3c51a99edb6e646d172b8f4ba4186a 100644 (file)
@@ -2422,6 +2422,28 @@ sub add_see_also {
                            { url => $input, reason => 'id' });
         }
     }
+    # Google Code URLs
+    elsif ($uri->authority =~ /^code.google.com$/) {
+        # Google Code URLs only have one form:
+        #   http(s)://code.google.com/p/PROJECT_NAME/issues/detail?id=1234
+        my $project_name;
+        if ($uri->path =~ m|^/p/([^/]+)/issues/detail$|) {
+            $project_name = $1;
+        } else {
+            ThrowUserError('bug_url_invalid', 
+                           { url => $input });
+        }
+        my $bug_id = $uri->query_param('id');
+        detaint_natural($bug_id);
+        if (!$bug_id) {
+            ThrowUserError('bug_url_invalid', 
+                           { url => $input, reason => 'id' });
+        }
+        # While Google Code URLs can be either HTTP or HTTPS,
+        # always go with the HTTP scheme, as that's the default.
+        $result = "http://code.google.com/p/" . $project_name .
+                  "/issues/detail?id=" . $bug_id;
+    }
     # Bugzilla URLs
     else {
         if ($uri->path !~ /show_bug\.cgi$/) {