Roundcube Community Forum

 

HTML email not displaying properly

Started by datadyne, September 11, 2017, 03:37:54 PM

Previous topic - Next topic

datadyne

All HTML emails received are having all of the html tags stripped. I traced the problem to rcube_washtml.php. Essentially, every instance of $node->tagName is returning NULL, no matter what is passed to the wash method.

As a workaround I replaced all instances of $node->tagName with $node->nodeName, and everything appears to now be working.

-- Extra Information --
My attempts at trying to figure out what is happening so far have been this.
I made a standalone copy of rcube_washtml (and the referenced rcube_base_replacer). https://pastebin.com/vVA4DY84
Added a var_dump($node->tagName); on line 323 for testing.

I've been testing on the HTML portion of an actual email I received: https://pastebin.com/ty9fiiNg (hopefully all personal information removed).

And I've been testing with the following code

require_once 'rcube_washtml.php'; // First pastebin link

//Options that I got from a var_dump of the options used on my server, removed cid_map as token is likely useless for my testing
$options = array(
    "show_washed"=> false,
    "allow_remote"=> false,
    "blocked_src"=> "program/resources/blocked.gif",
    "charset"=> "UTF-8",
//    "cid_map"=> array(
//        "cid:mouser-service-31B6CFD4"=> "./?_task=mail&_action=get&_mbox=INBOX&_uid=642&_token=wduAsrwQ1o462H4s3dBk7WAVQAzRY7rd&_part=2&_embed=1&_mimeclass=image"
//    ),
    "html_elements"=> array(0=> "body"),
);
$washer = new rcube_washtml($options);
$email = file_get_contents('email.html'); // Second pastebin link
$washer->wash($email);

When I run this on the server running Roundcube, it works perfectly, and prints out all of the tag names inside of the email. So I doubt this is an issue with my server environment. However, if I add the var_dump($node->tagName); inside the live rcube_washtml.php file inside of Roundcube, at the top of all my emails it prints out a NULL for each element. When the tagName property is NULL, the dumpHtml method of rcube_washtml defaults to replacing every tag with $dump .= '<!-- ' . htmlspecialchars($node->tagName, ENT_QUOTES) . ' ignored -->'; which is exactly what I'm seeing when inspecting the html of my emails.

I'm really at a loss for what might be causing the tagName property to be empty for every DomElement. Any insight on what might be causing this would be appreciated.

alec

Your PHP configuration and even version can be different when invoked by CLI and http server. What PHP version?

jp-embedded

I am having this exact issue also after upgrading from ubuntu 16.04 to 16.04.4

your fix with replacing tag with node worked for me.