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
fa360bee
Commit
fa360bee
authored
Apr 09, 2016
by
Frédéric Buclin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 1261538 - Bugzilla is unable to access attachment.cgi when ssl_redirect = true and using Plack
r=dylan
parent
60299ec5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
21 deletions
+39
-21
Bugzilla.pm
Bugzilla.pm
+0
-5
CGI.pm
Bugzilla/CGI.pm
+24
-8
Util.pm
Bugzilla/Util.pm
+15
-8
No files found.
Bugzilla.pm
View file @
fa360bee
...
@@ -131,11 +131,6 @@ sub init_page {
...
@@ -131,11 +131,6 @@ sub init_page {
my
$script
=
basename
(
$0
);
my
$script
=
basename
(
$0
);
# Because of attachment_base, attachment.cgi handles this itself.
if
(
$script
ne
'attachment.cgi'
)
{
do_ssl_redirect_if_required
();
}
# If Bugzilla is shut down, do not allow anything to run, just display a
# If Bugzilla is shut down, do not allow anything to run, just display a
# message to the user about the downtime and log out. Scripts listed in
# message to the user about the downtime and log out. Scripts listed in
# SHUTDOWNHTML_EXEMPT are exempt from this message.
# SHUTDOWNHTML_EXEMPT are exempt from this message.
...
...
Bugzilla/CGI.pm
View file @
fa360bee
...
@@ -53,10 +53,18 @@ sub new {
...
@@ -53,10 +53,18 @@ sub new {
# Make sure our outgoing cookie list is empty on each invocation
# Make sure our outgoing cookie list is empty on each invocation
$self
->
{
Bugzilla_cookie_list
}
=
[]
;
$self
->
{
Bugzilla_cookie_list
}
=
[]
;
my
$script
=
basename
(
$0
);
# attachment.cgi handles this itself.
if
(
$script
ne
'attachment.cgi'
)
{
$self
->
do_ssl_redirect_if_required
();
$self
->
redirect_to_urlbase
if
$self
->
url_is_attachment_base
;
}
# Path-Info is of no use for Bugzilla and interacts badly with IIS.
# Path-Info is of no use for Bugzilla and interacts badly with IIS.
# Moreover, it causes unexpected behaviors, such as totally breaking
# Moreover, it causes unexpected behaviors, such as totally breaking
# the rendering of pages.
# the rendering of pages.
my
$script
=
basename
(
$0
);
if
(
my
$path_info
=
$self
->
path_info
)
{
if
(
my
$path_info
=
$self
->
path_info
)
{
my
@whitelist
=
(
"rest.cgi"
);
my
@whitelist
=
(
"rest.cgi"
);
Bugzilla::Hook::
process
(
'path_info_whitelist'
,
{
whitelist
=>
\
@whitelist
});
Bugzilla::Hook::
process
(
'path_info_whitelist'
,
{
whitelist
=>
\
@whitelist
});
...
@@ -75,11 +83,6 @@ sub new {
...
@@ -75,11 +83,6 @@ sub new {
# Send appropriate charset
# Send appropriate charset
$self
->
charset
(
'UTF-8'
);
$self
->
charset
(
'UTF-8'
);
# Redirect to urlbase/sslbase if we are not viewing an attachment.
if
(
$self
->
url_is_attachment_base
and
$script
ne
'attachment.cgi'
)
{
$self
->
redirect_to_urlbase
();
}
# Check for errors
# Check for errors
# All of the Bugzilla code wants to do this, so do it here instead of
# All of the Bugzilla code wants to do this, so do it here instead of
# in each script
# in each script
...
@@ -539,7 +542,7 @@ sub redirect_to_urlbase {
...
@@ -539,7 +542,7 @@ sub redirect_to_urlbase {
sub
url_is_attachment_base
{
sub
url_is_attachment_base
{
my
(
$self
,
$id
)
=
@_
;
my
(
$self
,
$id
)
=
@_
;
return
0
if
!
use_attachbase
()
or
!
i_am_cgi
();
return
0
unless
use_attachbase
()
&&
i_am_cgi
();
my
$attach_base
=
Bugzilla
->
params
->
{
'attachment_base'
};
my
$attach_base
=
Bugzilla
->
params
->
{
'attachment_base'
};
# If we're passed an id, we only want one specific attachment base
# If we're passed an id, we only want one specific attachment base
# for a particular bug. If we're not passed an ID, we just want to
# for a particular bug. If we're not passed an ID, we just want to
...
@@ -556,7 +559,20 @@ sub url_is_attachment_base {
...
@@ -556,7 +559,20 @@ sub url_is_attachment_base {
$regex
=~
s/\\\%bugid\\\%/\\d+/
;
$regex
=~
s/\\\%bugid\\\%/\\d+/
;
}
}
$regex
=
"^$regex"
;
$regex
=
"^$regex"
;
return
(
$self
->
url
=~
$regex
)
?
1
:
0
;
my
$url
=
$self
->
url
;
# If we are behind a reverse proxy, we need to determine the original
# URL, else the comparison with the attachment_base URL will fail.
if
(
Bugzilla
->
params
->
{
'inbound_proxies'
})
{
# X-Forwarded-Proto is defined in RFC 7239.
my
$protocol
=
$ENV
{
HTTP_X_FORWARDED_PROTO
}
||
$self
->
protocol
;
my
$host
=
$self
->
virtual_host
;
# X-Forwarded-URI is not standard.
my
$uri
=
$ENV
{
HTTP_X_FORWARDED_URI
}
||
$self
->
request_uri
||
''
;
$url
=
"$protocol://$host$uri"
;
}
return
(
$url
=~
$regex
)
?
1
:
0
;
}
}
sub
set_dated_content_disp
{
sub
set_dated_content_disp
{
...
...
Bugzilla/Util.pm
View file @
fa360bee
...
@@ -250,29 +250,36 @@ sub i_am_webservice {
...
@@ -250,29 +250,36 @@ sub i_am_webservice {
sub
do_ssl_redirect_if_required
{
sub
do_ssl_redirect_if_required
{
return
if
!
i_am_cgi
();
return
if
!
i_am_cgi
();
return
if
!
Bugzilla
->
params
->
{
'ssl_redirect'
};
return
if
!
Bugzilla
->
params
->
{
'ssl_redirect'
};
return
if
!
Bugzilla
->
params
->
{
'sslbase'
};
my
$sslbase
=
Bugzilla
->
params
->
{
'sslbase'
};
# If we're already running under SSL, never redirect.
# If we're already running under SSL, never redirect.
if
(
Bugzilla
->
params
->
{
'inbound_proxies'
}
&&
uc
(
$ENV
{
HTTP_X_FORWARDED_PROTO
}
||
''
)
eq
'HTTPS'
)
{
return
;
}
return
if
uc
(
$ENV
{
HTTPS
}
||
''
)
eq
'ON'
;
return
if
uc
(
$ENV
{
HTTPS
}
||
''
)
eq
'ON'
;
# Never redirect if there isn't an sslbase.
return
if
!
$sslbase
;
# If called from Bugzilla::CGI->new itself, use the newly created
Bugzilla
->
cgi
->
redirect_to_https
();
# CGI object, to avoid deep recursions.
my
$cgi
=
shift
||
Bugzilla
->
cgi
;
$cgi
->
redirect_to_https
();
}
}
sub
correct_urlbase
{
sub
correct_urlbase
{
my
$ssl
=
Bugzilla
->
params
->
{
'ssl_redirect'
};
my
$urlbase
=
Bugzilla
->
params
->
{
'urlbase'
};
my
$urlbase
=
Bugzilla
->
params
->
{
'urlbase'
};
my
$sslbase
=
Bugzilla
->
params
->
{
'sslbase'
};
my
$sslbase
=
Bugzilla
->
params
->
{
'sslbase'
};
if
(
!
$sslbase
)
{
if
(
!
$sslbase
)
{
return
$urlbase
;
return
$urlbase
;
}
}
elsif
(
$ssl
)
{
elsif
(
Bugzilla
->
params
->
{
'ssl_redirect'
}
)
{
return
$sslbase
;
return
$sslbase
;
}
}
else
{
# Return what the user currently uses.
# Return what the user currently uses.
elsif
(
Bugzilla
->
params
->
{
'inbound_proxies'
})
{
return
(
uc
(
$ENV
{
HTTP_X_FORWARDED_PROTO
}
||
''
)
eq
'HTTPS'
)
?
$sslbase
:
$urlbase
;
}
else
{
return
(
uc
(
$ENV
{
HTTPS
}
||
''
)
eq
'ON'
)
?
$sslbase
:
$urlbase
;
return
(
uc
(
$ENV
{
HTTPS
}
||
''
)
eq
'ON'
)
?
$sslbase
:
$urlbase
;
}
}
}
}
...
...
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