Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
917d8b59
Commit
917d8b59
authored
11 years ago
by
Jared Hancock
Browse files
Options
Downloads
Patches
Plain Diff
Provide '--' message for empty messages
Provide fallback html2text mechanism if PHP xml extension is not available
parent
15d5dd63
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/class.mailfetch.php
+12
-6
12 additions, 6 deletions
include/class.mailfetch.php
include/class.mailparse.php
+12
-6
12 additions, 6 deletions
include/class.mailparse.php
include/html2text.php
+3
-0
3 additions, 0 deletions
include/html2text.php
with
27 additions
and
12 deletions
include/class.mailfetch.php
+
12
−
6
View file @
917d8b59
...
...
@@ -421,22 +421,28 @@ class MailFetcher {
if
(
$cfg
->
isHtmlThreadEnabled
())
{
if
(
$body
=
$this
->
getPart
(
$mid
,
'text/html'
,
$this
->
charset
))
{
//Cleanup the html.
$body
=
Format
::
safe_html
(
$body
);
//Balance html tags & neutralize unsafe tags.
$body
=
(
trim
(
$body
,
" <>br/
\t\n\r
"
))
?
Format
::
safe_html
(
$body
)
:
'--'
;
}
elseif
(
$body
=
$this
->
getPart
(
$mid
,
'text/plain'
,
$this
->
charset
))
{
$body
=
Format
::
htmlchars
(
$body
);
$body
=
"<div style=
\"
white-space:pre-wrap
\"
>
$body
</div>"
;
$body
=
trim
(
$body
)
?
sprintf
(
'<div style="white-space:pre-wrap">%s</div>'
,
Format
::
htmlchars
(
$body
))
:
'--'
;
}
}
else
{
if
(
$body
=
$this
->
getPart
(
$mid
,
'text/plain'
,
$this
->
charset
))
{
//Cleanup the html.
$body
=
Format
::
htmlchars
(
$body
);
$body
=
"<div style=
\"
white-space:pre-wrap
\"
>
$body
</div>"
;
}
elseif
(
$body
=
$this
->
getPart
(
$mid
,
'text/html'
,
$this
->
charset
))
{
$body
=
convert_html_to_text
(
$body
,
100
);
$body
=
convert_html_to_text
(
Format
::
safe_html
(
$body
)
,
100
);
}
$body
=
trim
(
$body
)
?
sprintf
(
'<div style="white-space:pre-wrap">%s</div>'
,
$body
)
:
'--'
;
}
return
$body
;
}
...
...
This diff is collapsed.
Click to expand it.
include/class.mailparse.php
+
12
−
6
View file @
917d8b59
...
...
@@ -160,23 +160,29 @@ class Mail_Parse {
if
(
$cfg
->
isHtmlThreadEnabled
())
{
if
(
$body
=
$this
->
getPart
(
$this
->
struct
,
'text/html'
))
{
//Cleanup the html.
$body
=
Format
::
safe_html
(
$body
);
//Balance html tags & neutralize unsafe tags.
// Cleanup the html -- Balance html tags & neutralize unsafe tags.
$body
=
(
trim
(
$body
,
" <>br/
\t\n\r
"
))
?
Format
::
safe_html
(
$body
)
:
'--'
;
}
elseif
(
$body
=
$this
->
getPart
(
$this
->
struct
,
'text/plain'
))
{
$body
=
Format
::
htmlchars
(
$body
);
$body
=
"<div style=
\"
white-space:pre-wrap
\"
>
$body
</div>"
;
$body
=
trim
(
$body
)
?
sprintf
(
'<div style="white-space:pre-wrap">%s</div>'
,
Format
::
htmlchars
(
$body
))
:
'--'
;
}
}
else
{
if
(
$body
=
$this
->
getPart
(
$this
->
struct
,
'text/plain'
))
{
//Cleanup the html.
$body
=
Format
::
htmlchars
(
$body
);
$body
=
"<div style=
\"
white-space:pre-wrap
\"
>
$body
</div>"
;
}
elseif
(
$body
=
$this
->
getPart
(
$this
->
struct
,
'text/html'
))
{
$body
=
convert_html_to_text
(
$body
,
100
);
}
$body
=
trim
(
$body
)
?
sprintf
(
'<div style="white-space:pre-wrap">%s</div>'
,
$body
)
:
'--'
;
}
return
$body
;
}
...
...
This diff is collapsed.
Click to expand it.
include/html2text.php
+
3
−
0
View file @
917d8b59
...
...
@@ -27,6 +27,9 @@
function
convert_html_to_text
(
$html
,
$width
=
74
)
{
$html
=
fix_newlines
(
$html
);
if
(
!
extension_loaded
(
'xml'
))
return
strip_tags
(
$html
);
$doc
=
new
DOMDocument
(
'1.0'
,
'utf-8'
);
if
(
!@
$doc
->
loadHTML
(
$html
))
return
$html
;
...
...
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