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
3a2858fc
Commit
3a2858fc
authored
Nov 23, 2003
by
justdave%syndicomm.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 226027: Use the Perl CGI module to send cookies.
r=bbaetz, a=justdave
parent
83cdee1c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
8 deletions
+45
-8
CGI.pm
Bugzilla/CGI.pm
+45
-8
No files found.
Bugzilla/CGI.pm
View file @
3a2858fc
...
...
@@ -24,6 +24,7 @@ use strict;
package
Bugzilla::
CGI
;
use
CGI
qw(-no_xhtml -oldstyle_urls :private_tempfiles :unique_headers)
;
use
CGI::
Util
qw(rearrange)
;
use
base
qw(CGI)
;
...
...
@@ -45,6 +46,9 @@ sub new {
my
$self
=
$class
->
SUPER::
new
(
@args
);
# Make sure our outgoing cookie list is empty on each invocation
$self
->
{
Bugzilla_cookie_list
}
=
[]
;
# Make sure that we don't send any charset headers
$self
->
charset
(
''
);
...
...
@@ -116,13 +120,48 @@ sub multipart_init {
return
$self
->
SUPER::
multipart_init
(
@_
);
}
# Override header so we can add the cookies in
sub
header
{
my
$self
=
shift
;
# Add the cookies in if we have any
if
(
scalar
(
@
{
$self
->
{
Bugzilla_cookie_list
}}))
{
if
(
scalar
(
@_
)
==
1
)
{
# if there's only one parameter, then it's a Content-Type.
# Since we're adding parameters we have to name it.
unshift
(
@_
,
'-type'
=>
shift
(
@_
));
}
unshift
(
@_
,
'-cookie'
=>
$self
->
{
Bugzilla_cookie_list
});
}
return
$self
->
SUPER::
header
(
@_
);
}
# We override the entirety of multipart_start instead of falling through to
# SUPER because the built-in one can't deal with cookies in any kind of sane
# way. This sub is gratuitously swiped from the real CGI.pm, but fixed so
# it actually works (but only as much as we need it to).
sub
multipart_start
{
my
(
@header
);
my
(
$self
,
@p
)
=
@_
;
my
(
$type
,
@other
)
=
rearrange
([[
'TYPE'
,
'CONTENT_TYPE'
,
'CONTENT-TYPE'
]],
@p
);
$type
=
$type
||
'text/html'
;
push
(
@header
,
"Content-Type: $type"
);
# Add the cookies in if we have any
if
(
scalar
(
@
{
$self
->
{
Bugzilla_cookie_list
}}))
{
foreach
my
$cookie
(
@
{
$self
->
{
Bugzilla_cookie_list
}})
{
push
@header
,
"Set-Cookie: $cookie"
;
}
}
my
$header
=
join
(
$
CGI::
CRLF
,
@header
)
.
"${CGI::CRLF}${CGI::CRLF}"
;
return
$header
;
}
# The various parts of Bugzilla which create cookies don't want to have to
# pass them arround to all of the callers. Instead, store them locally here,
# and then output as required from |headers|.
# This is done instead of just printing the result from the script, because
# we need to use |$r->header_out| under mod_perl (which is what CGI.pm
# does, and we need to match, plus if we don't |print| anything, we can turn
# off mod_perl/Apache's header parsing for a small perf gain)
# and then output as required from |header|.
sub
send_cookie
{
my
$self
=
shift
;
...
...
@@ -134,9 +173,7 @@ sub send_cookie {
# we're expiring an entry.
require
CGI::
Cookie
;
my
$cookie
=
CGI::
Cookie
->
new
(
@_
);
# XXX - mod_perl
print
"Set-Cookie: $cookie\r\n"
;
push
@
{
$self
->
{
Bugzilla_cookie_list
}},
$cookie
;
return
;
}
...
...
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