Skip to content

Multi-line HTML comments mess with EmailReplyParser #92

@tomfotherby

Description

@tomfotherby

One of our emails has a multi-line HTML comment in it and I noticed it messes with EmailReplyParser.

Example PHP code:

<?php
        $parser = new EmailReplyParser\Parser\EmailParser();

        $emailContent = "Start of test message,
        <!--
         a multi-line HTML comment
        -->
         End of of test message.";

        echo $parser->parse($emailContent)->getVisibleText();

Outputs:

Start of test message,
<!--
 a multi-line HTML comment%

⚠️ Notice that it did not output "End of of test message."


The workaround is to remove the comments before giving the content to EmailReplyParser.

        // Remove HTML comments from email content (because the EmailReplyParser doesn't like them)
        $emailContent = preg_replace('/<!--(.|\s)*?-->/', '', $text);
        echo $parser->parse($emailContent)->getVisibleText();

Using EmailReplyParser v2.10.0 with PHP 7.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions