Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
1f61f312
Commit
1f61f312
authored
12 years ago
by
Dominik Eckelmann
Browse files
Options
Downloads
Patches
Plain Diff
remove empty BCC/CC mail headers
Empty BCC/CC headers may cause errors on IIS.
parent
78f0e832
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
_test/tests/inc/mailer.test.php
+17
-0
17 additions, 0 deletions
_test/tests/inc/mailer.test.php
inc/Mailer.class.php
+11
-0
11 additions, 0 deletions
inc/Mailer.class.php
with
28 additions
and
0 deletions
_test/tests/inc/mailer.test.php
+
17
−
0
View file @
1f61f312
...
...
@@ -7,6 +7,14 @@ class TestMailer extends Mailer {
public
function
prop
(
$name
){
return
$this
->
$name
;
}
public
function
&
propRef
(
$name
)
{
return
$this
->
$name
;
}
public
function
prepareHeaders
()
{
return
parent
::
prepareHeaders
();
}
}
class
mailer_test
extends
DokuWikiTest
{
...
...
@@ -90,5 +98,14 @@ class mailer_test extends DokuWikiTest {
}
}
function
test_emptyBCCorCC
()
{
$mail
=
new
TestMailer
();
$headers
=
&
$mail
->
propRef
(
'headers'
);
$headers
[
'Bcc'
]
=
''
;
$headers
[
'Cc'
]
=
''
;
$header
=
$mail
->
prepareHeaders
();
$this
->
assertEquals
(
0
,
preg_match
(
'/(^|\n)Bcc: (\n|$)/'
,
$header
),
'Bcc found in headers.'
);
$this
->
assertEquals
(
0
,
preg_match
(
'/(^|\n)Cc: (\n|$)/'
,
$header
),
'Bcc found in headers.'
);
}
}
//Setup VIM: ex: et ts=4 :
This diff is collapsed.
Click to expand it.
inc/Mailer.class.php
+
11
−
0
View file @
1f61f312
...
...
@@ -553,6 +553,7 @@ class Mailer {
* @returns string the headers
*/
protected
function
prepareHeaders
()
{
$this
->
removeEmptyBccOrCcHeader
();
$headers
=
''
;
foreach
(
$this
->
headers
as
$key
=>
$val
)
{
$headers
.
=
"
$key
:
$val
"
.
MAILHEADER_EOL
;
...
...
@@ -560,6 +561,16 @@ class Mailer {
return
$headers
;
}
/**
* Removes empty BCC and CC Header.
*
* Empty BCC/CC Header can cause an error with Microsoft IIS.
*/
protected
function
removeEmptyBccOrCcHeader
()
{
if
(
isset
(
$this
->
headers
[
'Bcc'
])
&&
empty
(
$this
->
headers
[
'Bcc'
]))
unset
(
$this
->
headers
[
'Bcc'
]);
if
(
isset
(
$this
->
headers
[
'Cc'
])
&&
empty
(
$this
->
headers
[
'Cc'
]))
unset
(
$this
->
headers
[
'Cc'
]);
}
/**
* return a full email with all headers
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment