Ask not what osTicket community can do for you - ask what you can do for osTicket community

Go Back   osTicket Forums > Project Tools > osTicket Bug Tracker > Bug

Issue Type Bug   Project osTicket Bug Tracker
HTML email not parsed if   is there in mail body
If email format is HTML and it contains   tag, then html_entity_decode doesn't parse it correctly and mail is truncated
Category Unknown
Affected Version 1.6 Stable
Priority 5 - Medium
Status Unconfirmed
Fixed Version (none)
Submitted 08-27-2010
Assigned Users (none) Tags (none)

issueid=224 08-27-2010 07:24 AM
Junior Member
HTML email not parsed if   is there in mail body
If email format is HTML and it contains   tag, then html_entity_decode doesn't parse it correctly and mail is truncated

I am using Thunderbird 3.1 to send emails on Ubuntu 9.04. The default mail composition format is 'HTML only'. Sample mail content as copied from Thunderbird is

HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#ffffff" text="#000099">
    <font size="-1"><font face="Arial">This is a mail with two&nbsp; spaces.
        Let's see how it goes<br>
        <br>
        Regards<br>
        Vivek<br>
      </font></font>
  </body>

</html>
When I sent a mail which had double spaces, Thunderbird converted one of the space to &nbsp; as seen in the above code. That mail was not parsed correctly by osTicket after being fetched via POP3. osTicket's interface showed only the text

Code:
This is a mail with two
I tried to understand the reason and following is what I found

The function striptags() uses html_entity_decode. The PHP function html_entity_decode uses ISO8859-1 charset by default. However, ISO8859-1 charset doesn't parse &nbsp; correctly, and hence the mail is lost.

An alternate version, which works for me is

PHP Code:
    function striptags($string) {
//        return strip_tags(html_entity_decode($string)); //strip all tags ...no mercy!
        
return trim(strip_tags(html_entity_decode($string,ENT_COMPAT,'UTF-8'))); //strip all tags ...no mercy!
    

I added trim() in there so that extra spaces are trimmed and the mail looks better. Not sure what the implications are of using UTF-8 instead of ISO8859-1 though, so may be it can be reviewed.

Thanks
Vivek Kapoor
Reply

09-24-2010 11:50 AM
Junior Member
 
This has also happened in our system. I was able to duplicate the issue and applied the code changes and things worked fine.
Reply
11-30-2012 11:05 AM
Junior Member
 
Hey there!

Thank you for this solution - however, now my ticket locking doesn't work (it says the ticket is currently locked, press ok to override). Is there a mod to this mod I can use?
Reply
01-03-2013 03:00 PM
Junior Member
 
.
Reply

Issue Tools
Subscribe to this issue

All times are GMT -4. The time now is 01:05 AM.