Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
4c236f41
Commit
4c236f41
authored
Jun 17, 2012
by
Matt Selsky
Committed by
Frédéric Buclin
Jun 17, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 759030: Clean up Bugzilla::BugUrl modules
r=timello a=LpSolit
parent
35bf9943
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
96 deletions
+58
-96
Debian.pm
Bugzilla/BugUrl/Debian.pm
+12
-20
Google.pm
Bugzilla/BugUrl/Google.pm
+10
-21
JIRA.pm
Bugzilla/BugUrl/JIRA.pm
+4
-7
Launchpad.pm
Bugzilla/BugUrl/Launchpad.pm
+13
-18
MantisBT.pm
Bugzilla/BugUrl/MantisBT.pm
+3
-6
SourceForge.pm
Bugzilla/BugUrl/SourceForge.pm
+12
-17
Trac.pm
Bugzilla/BugUrl/Trac.pm
+4
-7
No files found.
Bugzilla/BugUrl/Debian.pm
View file @
4c236f41
...
...
@@ -9,16 +9,20 @@ package Bugzilla::BugUrl::Debian;
use
strict
;
use
base
qw(Bugzilla::BugUrl)
;
use
Bugzilla::
Error
;
use
Bugzilla::
Util
;
###############################
#### Methods ####
###############################
sub
should_handle
{
my
(
$class
,
$uri
)
=
@_
;
return
(
$uri
->
authority
=~
/^bugs.debian.org$/i
)
?
1
:
0
;
# Debian BTS URLs can look like various things:
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1234
# http://bugs.debian.org/1234
return
(
$uri
->
authority
=~
/^bugs.debian.org$/i
and
((
$uri
->
path
=~
/bugreport\.cgi$/
and
$uri
->
query_param
(
'bug'
)
=~
m
|^\
d
+
$|
)
or
$uri
->
path
=~
m
|^/\
d
+
$|
))
?
1
:
0
;
}
sub
_check_value
{
...
...
@@ -26,24 +30,12 @@ sub _check_value {
my
$uri
=
$class
->
SUPER::
_check_value
(
@_
);
# 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
=>
$uri
->
path
,
reason
=>
'id'
});
}
# This is the shortest standard URL form for Debian BTS URLs,
# and so we reduce all URLs to this.
return
new
URI
(
"http://bugs.debian.org/"
.
$bug_id
);
$uri
->
path
=~
m
|^/
(
\
d
+
)
$|
||
$uri
->
query_param
(
'bug'
)
=~
m
|^
(
\
d
+
)
$|
;
$uri
=
new
URI
(
"http://bugs.debian.org/$1"
);
return
$uri
;
}
1
;
Bugzilla/BugUrl/Google.pm
View file @
4c236f41
...
...
@@ -9,16 +9,18 @@ package Bugzilla::BugUrl::Google;
use
strict
;
use
base
qw(Bugzilla::BugUrl)
;
use
Bugzilla::
Error
;
use
Bugzilla::
Util
;
###############################
#### Methods ####
###############################
sub
should_handle
{
my
(
$class
,
$uri
)
=
@_
;
return
(
$uri
->
authority
=~
/^code.google.com$/i
)
?
1
:
0
;
# Google Code URLs only have one form:
# http(s)://code.google.com/p/PROJECT_NAME/issues/detail?id=1234
return
(
$uri
->
authority
=~
/^code.google.com$/i
and
$uri
->
path
=~
m
|^
/p/
[
^
/]+/iss
ues
/
detail
$|
and
$uri
->
query_param
(
'id'
)
=~
/^\d+$/
)
?
1
:
0
;
}
sub
_check_value
{
...
...
@@ -26,26 +28,13 @@ sub _check_value {
$uri
=
$class
->
SUPER::
_check_value
(
$uri
);
my
$value
=
$uri
->
as_string
;
# 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/
([
^
/]+)/iss
ues
/
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'
});
}
# While Google Code URLs can be either HTTP or HTTPS,
# always go with the HTTP scheme, as that's the default.
$value
=
"http://code.google.com/p/"
.
$project_name
.
"/issues/detail?id="
.
$bug_id
;
if
(
$uri
->
scheme
eq
'https'
)
{
$uri
->
scheme
(
'http'
);
}
return
new
URI
(
$value
)
;
return
$uri
;
}
1
;
Bugzilla/BugUrl/JIRA.pm
View file @
4c236f41
...
...
@@ -9,15 +9,16 @@ package Bugzilla::BugUrl::JIRA;
use
strict
;
use
base
qw(Bugzilla::BugUrl)
;
use
Bugzilla::
Error
;
use
Bugzilla::
Util
;
###############################
#### Methods ####
###############################
sub
should_handle
{
my
(
$class
,
$uri
)
=
@_
;
# JIRA URLs have only one basic form (but the jira is optional):
# https://issues.apache.org/jira/browse/KEY-1234
# http://issues.example.com/browse/KEY-1234
return
(
$uri
->
path
=~
m
|
/browse/
[
A
-
Z
][
A
-
Z
]
+-\
d
+
$|
)
?
1
:
0
;
}
...
...
@@ -26,10 +27,6 @@ sub _check_value {
my
$uri
=
$class
->
SUPER::
_check_value
(
@_
);
# JIRA URLs have only one basic form (but the jira is optional):
# https://issues.apache.org/jira/browse/KEY-1234
# http://issues.example.com/browse/KEY-1234
# Make sure there are no query parameters.
$uri
->
query
(
undef
);
# And remove any # part if there is one.
...
...
Bugzilla/BugUrl/Launchpad.pm
View file @
4c236f41
...
...
@@ -9,15 +9,19 @@ package Bugzilla::BugUrl::Launchpad;
use
strict
;
use
base
qw(Bugzilla::BugUrl)
;
use
Bugzilla::
Error
;
###############################
#### Methods ####
###############################
sub
should_handle
{
my
(
$class
,
$uri
)
=
@_
;
return
(
$uri
->
authority
=~
/launchpad.net$/
)
?
1
:
0
;
# Launchpad bug URLs can look like various things:
# https://bugs.launchpad.net/ubuntu/+bug/1234
# https://launchpad.net/bugs/1234
# All variations end with either "/bugs/1234" or "/+bug/1234"
return
(
$uri
->
authority
=~
/launchpad.net$/
and
$uri
->
path
=~
m
|
bugs
?
/\
d
+
$|
)
?
1
:
0
;
}
sub
_check_value
{
...
...
@@ -25,21 +29,12 @@ sub _check_value {
$uri
=
$class
->
SUPER::
_check_value
(
$uri
);
my
$value
=
$uri
->
as_string
;
# Launchpad bug URLs can look like various things:
# https://bugs.launchpad.net/ubuntu/+bug/1234
# https://launchpad.net/bugs/1234
# All variations end with either "/bugs/1234" or "/+bug/1234"
if
(
$uri
->
path
=~
m
|
bugs
?
/
(
\
d
+
)
$|
)
{
# This is the shortest standard URL form for Launchpad bugs,
# and so we reduce all URLs to this.
$value
=
"https://launchpad.net/bugs/$1"
;
}
else
{
ThrowUserError
(
'bug_url_invalid'
,
{
url
=>
$value
,
reason
=>
'id'
});
}
return
new
URI
(
$value
);
# This is the shortest standard URL form for Launchpad bugs,
# and so we reduce all URLs to this.
$uri
->
path
=~
m
|
bugs
?
/
(
\
d
+
)
$|
;
$uri
=
new
URI
(
"https://launchpad.net/bugs/$1"
);
return
$uri
;
}
1
;
Bugzilla/BugUrl/MantisBT.pm
View file @
4c236f41
...
...
@@ -9,15 +9,15 @@ package Bugzilla::BugUrl::MantisBT;
use
strict
;
use
base
qw(Bugzilla::BugUrl)
;
use
Bugzilla::
Error
;
use
Bugzilla::
Util
;
###############################
#### Methods ####
###############################
sub
should_handle
{
my
(
$class
,
$uri
)
=
@_
;
# MantisBT URLs look like the following ('bugs' directory is optional):
# http://www.mantisbt.org/bugs/view.php?id=1234
return
(
$uri
->
path_query
=~
m
|
view
\.
php
\
?
id
=\
d
+
$|
)
?
1
:
0
;
}
...
...
@@ -26,9 +26,6 @@ sub _check_value {
my
$uri
=
$class
->
SUPER::
_check_value
(
@_
);
# MantisBT URLs look like the following ('bugs' directory is optional):
# http://www.mantisbt.org/bugs/view.php?id=1234
# Remove any # part if there is one.
$uri
->
fragment
(
undef
);
...
...
Bugzilla/BugUrl/SourceForge.pm
View file @
4c236f41
...
...
@@ -9,17 +9,21 @@ package Bugzilla::BugUrl::SourceForge;
use
strict
;
use
base
qw(Bugzilla::BugUrl)
;
use
Bugzilla::
Error
;
use
Bugzilla::
Util
;
###############################
#### Methods ####
###############################
sub
should_handle
{
my
(
$class
,
$uri
)
=
@_
;
# SourceForge tracker URLs have only one form:
# http://sourceforge.net/tracker/?func=detail&aid=111&group_id=111&atid=111
return
(
$uri
->
authority
=~
/^sourceforge.net$/i
and
$uri
->
path
=~
m
|
/tracker/
|
)
?
1
:
0
;
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
;
}
sub
_check_value
{
...
...
@@ -27,19 +31,10 @@ sub _check_value {
my
$uri
=
$class
->
SUPER::
_check_value
(
@_
);
# SourceForge tracker URLs have only one form:
# http://sourceforge.net/tracker/?func=detail&aid=111&group_id=111&atid=111
if
(
$uri
->
query_param
(
'func'
)
eq
'detail'
and
$uri
->
query_param
(
'aid'
)
and
$uri
->
query_param
(
'group_id'
)
and
$uri
->
query_param
(
'atid'
))
{
# Remove any # part if there is one.
$uri
->
fragment
(
undef
);
return
$uri
;
}
else
{
my
$value
=
$uri
->
as_string
;
ThrowUserError
(
'bug_url_invalid'
,
{
url
=>
$value
});
}
# Remove any # part if there is one.
$uri
->
fragment
(
undef
);
return
$uri
;
}
1
;
Bugzilla/BugUrl/Trac.pm
View file @
4c236f41
...
...
@@ -9,15 +9,16 @@ package Bugzilla::BugUrl::Trac;
use
strict
;
use
base
qw(Bugzilla::BugUrl)
;
use
Bugzilla::
Error
;
use
Bugzilla::
Util
;
###############################
#### Methods ####
###############################
sub
should_handle
{
my
(
$class
,
$uri
)
=
@_
;
# Trac URLs can look like various things:
# http://dev.mutt.org/trac/ticket/1234
# http://trac.roundcube.net/ticket/1484130
return
(
$uri
->
path
=~
m
|
/ticket/
\
d
+
$|
)
?
1
:
0
;
}
...
...
@@ -26,10 +27,6 @@ sub _check_value {
my
$uri
=
$class
->
SUPER::
_check_value
(
@_
);
# Trac URLs can look like various things:
# http://dev.mutt.org/trac/ticket/1234
# http://trac.roundcube.net/ticket/1484130
# Make sure there are no query parameters.
$uri
->
query
(
undef
);
# And remove any # part if there is one.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment