From 62ef98df72e36fc4f32d45c8b9b44c9c07b289c9 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 24 May 2015 01:23:22 -0400 Subject: [PATCH bugzilla] BugUrl: add GNU Savannah support X-Gentoo-Bug: 362977 X-Gentoo-Bug-URL: https://bugs.gentoo.org/362977 --- Bugzilla/BugUrl.pm | 1 + Bugzilla/BugUrl/Savannah.pm | 45 +++++++++++++++++++++++++ template/en/default/global/user-error.html.tmpl | 1 + 3 files changed, 47 insertions(+) create mode 100644 Bugzilla/BugUrl/Savannah.pm diff --git a/Bugzilla/BugUrl.pm b/Bugzilla/BugUrl.pm index 8689e8a..6266090 100644 --- a/Bugzilla/BugUrl.pm +++ b/Bugzilla/BugUrl.pm @@ -56,6 +56,7 @@ use constant SUB_CLASSES => qw( Bugzilla::BugUrl::JIRA Bugzilla::BugUrl::Trac Bugzilla::BugUrl::MantisBT + Bugzilla::BugUrl::Savannah Bugzilla::BugUrl::SourceForge Bugzilla::BugUrl::GitHub ); diff --git a/Bugzilla/BugUrl/Savannah.pm b/Bugzilla/BugUrl/Savannah.pm new file mode 100644 index 0000000..531f30e --- /dev/null +++ b/Bugzilla/BugUrl/Savannah.pm @@ -0,0 +1,45 @@ +# 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::Savannah; +use strict; +use base qw(Bugzilla::BugUrl); + +############################### +#### Methods #### +############################### + +sub should_handle { + my ($class, $uri) = @_; + + # Savannah URLs look like the following (the index.php is optional): + # https://savannah.gnu.org/bugs/index.php?107657 + # https://savannah.gnu.org/patch/index.php?107657 + # https://savannah.gnu.org/support/index.php?107657 + # https://savannah.gnu.org/task/index.php?107657 + return ($uri->path_query =~ m|/(bugs\|patch\|support\|task)/?(index\.php)?\?\d+$|) ? 1 : 0; +} + +sub _check_value { + my $class = shift; + + my $uri = $class->SUPER::_check_value(@_); + + # Remove any # part if there is one. + $uri->fragment(undef); + + # Savannah HTTP URLs redirect to HTTPS, so just use the HTTPS scheme. + $uri->scheme('https'); + + # Strip the index.php if there is one. + $uri->path =~ m|(/[^/]+)/?(index\.php)?$|; + $uri->path("$1/"); + + return $uri; +} + +1; diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index 1baba99..acb4275 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -274,6 +274,7 @@
  • A b[% %]ug in a MantisBT installation.
  • A b[% %]ug on sourceforge.net.
  • An issue on github.com.
  • +
  • A tracker item on a GNU Savannah forge.
  • [% Hook.process('bug_url_invalid_tracker') %] [% END %] -- 2.4.1