Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
0b6f4435
Commit
0b6f4435
authored
12 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Convert decoded header text to the desired charset/endoding.
parent
463484ad
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/pear/Mail/mimeDecode.php
+20
-8
20 additions, 8 deletions
include/pear/Mail/mimeDecode.php
with
20 additions
and
8 deletions
include/pear/Mail/mimeDecode.php
+
20
−
8
View file @
0b6f4435
...
@@ -28,8 +28,8 @@
...
@@ -28,8 +28,8 @@
* - Redistributions in binary form must reproduce the above copyright
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* documentation and/or other materials provided with the distribution.
* - Neither the name of the authors, nor the names of its contributors
* - Neither the name of the authors, nor the names of its contributors
* may be used to endorse or promote products derived from this
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
* software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
...
@@ -174,9 +174,9 @@ class Mail_mimeDecode extends PEAR
...
@@ -174,9 +174,9 @@ class Mail_mimeDecode extends PEAR
function
getHeader
()
{
function
getHeader
()
{
return
$this
->
_header
;
return
$this
->
_header
;
}
}
/**
/**
* Begins the decoding process. If called statically
* Begins the decoding process. If called statically
...
@@ -219,6 +219,8 @@ class Mail_mimeDecode extends PEAR
...
@@ -219,6 +219,8 @@ class Mail_mimeDecode extends PEAR
$params
[
'decode_bodies'
]
:
false
;
$params
[
'decode_bodies'
]
:
false
;
$this
->
_decode_headers
=
isset
(
$params
[
'decode_headers'
])
?
$this
->
_decode_headers
=
isset
(
$params
[
'decode_headers'
])
?
$params
[
'decode_headers'
]
:
false
;
$params
[
'decode_headers'
]
:
false
;
$this
->
_charset
=
isset
(
$params
[
'charset'
])
?
$params
[
'charset'
]
:
'UTF-8'
;
$structure
=
$this
->
_decode
(
$this
->
_header
,
$this
->
_body
);
$structure
=
$this
->
_decode
(
$this
->
_header
,
$this
->
_body
);
if
(
$structure
===
false
)
{
if
(
$structure
===
false
)
{
...
@@ -374,7 +376,7 @@ class Mail_mimeDecode extends PEAR
...
@@ -374,7 +376,7 @@ class Mail_mimeDecode extends PEAR
}
}
for
(
$i
=
0
;
$i
<
count
(
$structure
->
parts
);
$i
++
)
{
for
(
$i
=
0
;
$i
<
count
(
$structure
->
parts
);
$i
++
)
{
if
(
!
empty
(
$structure
->
headers
[
'content-type'
])
AND
substr
(
strtolower
(
$structure
->
headers
[
'content-type'
]),
0
,
8
)
==
'message/'
)
{
if
(
!
empty
(
$structure
->
headers
[
'content-type'
])
AND
substr
(
strtolower
(
$structure
->
headers
[
'content-type'
]),
0
,
8
)
==
'message/'
)
{
$prepend
=
$prepend
.
$mime_number
.
'.'
;
$prepend
=
$prepend
.
$mime_number
.
'.'
;
$_mime_number
=
''
;
$_mime_number
=
''
;
...
@@ -394,7 +396,7 @@ class Mail_mimeDecode extends PEAR
...
@@ -394,7 +396,7 @@ class Mail_mimeDecode extends PEAR
$structure
->
mime_id
=
$prepend
.
$mime_number
;
$structure
->
mime_id
=
$prepend
.
$mime_number
;
$no_refs
?
$return
[
$prepend
.
$mime_number
]
=
''
:
$return
[
$prepend
.
$mime_number
]
=
&
$structure
;
$no_refs
?
$return
[
$prepend
.
$mime_number
]
=
''
:
$return
[
$prepend
.
$mime_number
]
=
&
$structure
;
}
}
return
$return
;
return
$return
;
}
}
...
@@ -567,6 +569,16 @@ class Mail_mimeDecode extends PEAR
...
@@ -567,6 +569,16 @@ class Mail_mimeDecode extends PEAR
break
;
break
;
}
}
//Convert decoded text to the desired charset.
if
(
$charset
&&
$this
->
_charset
&&
strcasecmp
(
$this
->
_charset
,
$charset
))
{
if
(
function_exists
(
'iconv'
))
$text
=
iconv
(
$charset
,
$this
->
_charset
.
'//IGNORE'
,
$text
);
elseif
(
function_exists
(
'mb_convert_encoding'
))
$text
=
mb_convert_encoding
(
$text
,
$this
->
_charset
,
$charset
);
elseif
(
!
strcasecmp
(
$this
->
_charset
,
'utf-8'
))
//forced blind utf8 encoding.
$text
=
function_exists
(
'imap_utf8'
)
?
imap_utf8
(
$text
)
:
utf8_encode
(
$text
);
}
$input
=
str_replace
(
$encoded
,
$text
,
$input
);
$input
=
str_replace
(
$encoded
,
$text
,
$input
);
}
}
...
@@ -698,7 +710,7 @@ class Mail_mimeDecode extends PEAR
...
@@ -698,7 +710,7 @@ class Mail_mimeDecode extends PEAR
/**
/**
* getSendArray() returns the arguments required for Mail::send()
* getSendArray() returns the arguments required for Mail::send()
* used to build the arguments for a mail::send() call
* used to build the arguments for a mail::send() call
*
*
* Usage:
* Usage:
* $mailtext = Full email (for example generated by a template)
* $mailtext = Full email (for example generated by a template)
...
@@ -741,7 +753,7 @@ class Mail_mimeDecode extends PEAR
...
@@ -741,7 +753,7 @@ class Mail_mimeDecode extends PEAR
}
}
$to
=
substr
(
$to
,
1
);
$to
=
substr
(
$to
,
1
);
return
array
(
$to
,
$header
,
$this
->
_body
);
return
array
(
$to
,
$header
,
$this
->
_body
);
}
}
/**
/**
* Returns a xml copy of the output of
* Returns a xml copy of the output of
...
...
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