Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-line HTML comments mess with EmailReplyParser #92

Open
tomfotherby opened this issue May 10, 2023 · 0 comments
Open

Multi-line HTML comments mess with EmailReplyParser #92

tomfotherby opened this issue May 10, 2023 · 0 comments

Comments

@tomfotherby
Copy link

tomfotherby commented May 10, 2023

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.

@tomfotherby tomfotherby changed the title Multi-line HTML comments mess with EmailParser Multi-line HTML comments mess with EmailReplyParser May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant