diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2023-07-10 22:15:28 -0700 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2023-07-10 22:15:28 -0700 |
commit | 4fbc0b916346c364525ebaa07ee784a614dff646 (patch) | |
tree | 1e0cc125a62d0c2195fd8e53f4c606f45cdf70f4 | |
parent | Merge branch 'master' into bugstest (diff) | |
parent | BugUrl: enhance Gerrit regex (diff) | |
download | bugzilla-4fbc0b916346c364525ebaa07ee784a614dff646.tar.gz bugzilla-4fbc0b916346c364525ebaa07ee784a614dff646.tar.bz2 bugzilla-4fbc0b916346c364525ebaa07ee784a614dff646.zip |
Merge remote-tracking branch 'origin/master' into bugstest
-rw-r--r-- | Bugzilla/BugUrl.pm | 2 | ||||
-rw-r--r-- | Bugzilla/BugUrl/Chromium.pm | 49 | ||||
-rw-r--r-- | Bugzilla/BugUrl/Gerrit.pm | 51 | ||||
-rw-r--r-- | Bugzilla/BugUrl/SourceForge.pm | 30 | ||||
-rw-r--r-- | template/en/default/global/user-error.html.tmpl | 4 |
5 files changed, 129 insertions, 7 deletions
diff --git a/Bugzilla/BugUrl.pm b/Bugzilla/BugUrl.pm index 9aa7ac7f5..674997c61 100644 --- a/Bugzilla/BugUrl.pm +++ b/Bugzilla/BugUrl.pm @@ -57,6 +57,7 @@ use constant SUB_CLASSES => qw( Bugzilla::BugUrl::Bugzilla::Local Bugzilla::BugUrl::Bugzilla Bugzilla::BugUrl::Launchpad + Bugzilla::BugUrl::Chromium Bugzilla::BugUrl::Flyspray Bugzilla::BugUrl::Google Bugzilla::BugUrl::Debian @@ -67,6 +68,7 @@ use constant SUB_CLASSES => qw( Bugzilla::BugUrl::GitHub Bugzilla::BugUrl::GitLab Bugzilla::BugUrl::Phabricator + Bugzilla::BugUrl::Gerrit ); ############################### diff --git a/Bugzilla/BugUrl/Chromium.pm b/Bugzilla/BugUrl/Chromium.pm new file mode 100644 index 000000000..dafe7f815 --- /dev/null +++ b/Bugzilla/BugUrl/Chromium.pm @@ -0,0 +1,49 @@ +# 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. + +package Bugzilla::BugUrl::Chromium; + +use 5.10.1; +use strict; +use warnings; + +use parent qw(Bugzilla::BugUrl); + +use Bugzilla::Error; +use Bugzilla::Util; + +############################### +#### Methods #### +############################### + +sub should_handle { + my ($class, $uri) = @_; + return ($uri->authority =~ /^bugs.chromium.org$/i) ? 1 : 0; +} + +sub _check_value { + my ($class, $uri) = @_; + + $uri = $class->SUPER::_check_value($uri); + + my $value = $uri->as_string; + my $project_name; + if ($uri->path =~ m|^/p/([^/]+)/issues/detail$|) { + $project_name = $1; + } else { + ThrowUserError('bug_url_invalid', { url => $value }); + } + my $bug_id = $uri->query_param('id'); + detaint_natural($bug_id); + if (!$bug_id) { + ThrowUserError('bug_url_invalid', { url => $value, reason => 'id' }); + } + + return URI->new($value); +} + +1; diff --git a/Bugzilla/BugUrl/Gerrit.pm b/Bugzilla/BugUrl/Gerrit.pm new file mode 100644 index 000000000..4cc278b7b --- /dev/null +++ b/Bugzilla/BugUrl/Gerrit.pm @@ -0,0 +1,51 @@ +# 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. + +package Bugzilla::BugUrl::Gerrit; + +use 5.10.1; +use strict; +use warnings; + +use parent qw(Bugzilla::BugUrl); + +############################### +#### Methods #### +############################### + +sub should_handle { + my ($class, $uri) = @_; + + # https://codereview.qt-project.org/c/qt/qtlocation/+/123 + # https://chromium-review.googlesource.com/c/chromium/src/+/123 + # https://gerrit.libreoffice.org/c/core/+/123 + if ($uri->path =~ /c\/[[:alnum:]]+\/(([[:alnum:]]+)\/)?\+\/([[:digit:]]+)/) { + return 1; + } + + # Gerrit Change URL: https://git.eclipse.org/r/#/c/26613/ + # Gerrit Change URL, specific patch set: https://git.eclipse.org/r/#/c/26613/4 + # https://git.eclipse.org/r/40031 + return ( ($uri->path =~ m|^/r/$| and $uri->fragment =~ m|^/c/\d+|) || + $uri->path =~ m|^/r/\d+|) ? 1 : 0; +} + +sub _check_value { + my ($class, $uri) = @_; + + $uri = $class->SUPER::_check_value($uri); + + # While Gerrit URLs can be either HTTP or HTTPS, + # always go with the HTTP scheme, as that's the default. + if ($uri->scheme eq 'http') { + $uri->scheme('https'); + } + + return $uri; +} + +1; diff --git a/Bugzilla/BugUrl/SourceForge.pm b/Bugzilla/BugUrl/SourceForge.pm index ffdde42f4..c79b83b84 100644 --- a/Bugzilla/BugUrl/SourceForge.pm +++ b/Bugzilla/BugUrl/SourceForge.pm @@ -22,12 +22,25 @@ sub should_handle { # SourceForge tracker URLs have only one form: # http://sourceforge.net/tracker/?func=detail&aid=111&group_id=111&atid=111 - return (lc($uri->authority) eq 'sourceforge.net' - and $uri->path =~ m|/tracker/| - and $uri->query_param('func') eq 'detail' - and $uri->query_param('aid') - and $uri->query_param('group_id') - and $uri->query_param('atid')) ? 1 : 0; + # SourceForge Allura ticket URLs have several forms: + # http://sourceforge.net/p/project/bugs/12345/ + # http://sourceforge.net/p/project/feature-requests/12345/ + # http://sourceforge.net/p/project/patches/12345/ + # http://sourceforge.net/p/project/support-requests/12345/ + return ( + lc($uri->authority) eq 'sourceforge.net' + and ( + ( + $uri->path eq '/tracker/' + and $uri->query_param('func') eq 'detail' + and $uri->query_param('aid') + and $uri->query_param('group_id') + and $uri->query_param('atid') + ) + or $uri->path + =~ m!^/p/[^/]+/(?:bugs|feature-requests|patches|support-requests)/\d+/?$! + ) + ) ? 1 : 0; } sub _check_value { @@ -38,6 +51,11 @@ sub _check_value { # Remove any # part if there is one. $uri->fragment(undef); + # Make sure the trailing slash is present + my $path = $uri->path; + $path =~ s!/*$!/!; + $uri->path($path); + return $uri; } diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index 4ebb0b95b..1c83afadb 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -286,14 +286,16 @@ <li>A b[% %]ug on launchpad.net.</li> <li>An issue on code.google.com.</li> <li>A b[% %]ug on b[% %]ugs.debian.org or deb[% %]ugs.gnu.org.</li> + <li>An issue on b[% %]ugs.chromium.org.</li> <li>An issue in a JIRA installation.</li> <li>A ticket in a Trac installation.</li> <li>A b[% %]ug in a MantisBT installation.</li> - <li>A b[% %]ug on sourceforge.net.</li> + <li>A b[% %]ug or ticket on sourceforge.net.</li> <li>An issue/pull request on github.com.</li> <li>An issue/merge request on a GitLab system.</li> <li>A task on a Flyspray tracking system.</li> <li>A revision, support ticket, or task in Phabricator.</li> + <li>A Gerrit change.</li> [% Hook.process('bug_url_invalid_tracker') %] </ul> [% END %] |