[GH-ISSUE #308] 🐛 Reply to a html message will not be displayed #268

Closed
opened 2026-02-25 21:34:36 +03:00 by kerem · 7 comments
Owner

Originally created by @ulfgebhardt on GitHub (Nov 30, 2018).
Original GitHub issue: https://github.com/cypht-org/cypht/issues/308

Originally assigned to: @jasonmunro on GitHub.

🐛 Bugreport

This describes a very rare bug, which might be due to a problem in the sending client.

If a Person replies to a HTML EMail, the response is in some cases not visible.
image

If you press reply, the Response becomes visible
image

Raw Mail:

Return-Path: <CENSORED>
X-Original-To: CENSORED
Delivered-To: CENSORED
Received: from CENSORED (CENSORED [CENSORED])
    by CENSORED (Postfix) with ESMTPS id 427FFF761EDF
    for <CENSORED>; Thu, 29 Nov 2018 13:21:03 +0100 (CET)
Authentication-Results: CENSORED;
    dkim=pass header.i=CENSORED;
    spf=neutral (sender IP is CENSORED) smtp.mailfrom=CENSORED smtp.helo=CENSORED
Received-SPF: neutral (CENSORED: CENSORED is neither permitted nor denied by domain of CENSORED) client-ip=CENSORED; envelope-from=CENSORED; helo=CENSORED;
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
    d=CENSORED; s=20140924;
    h=content-transfer-encoding:content-type:mime-version:to:from:subject:date:from;
    bh=CENSORED;
    b=CENSORED
X-HalOne-Cookie: CENSORED
X-HalOne-ID: CENSORED
Received: from [CENSORED] (unknown [CENSORED])
    by CENSORED (Halon) with ESMTPSA
    id CENSORED;
    Thu, 29 Nov 2018 12:21:02 +0000 (UTC)
Date: Thu, 29 Nov 2018 13:20:59 +0100
Subject: =?UTF-8?Q?AW:_=F0=9F=93=B1_DEMOCRACY_News_#12_=E2=80=93_Wir_sind?=
 =?UTF-8?Q?_10.000,_Entwicklungsstand_und_Redesign?=
From: "CENSORED" <CENSORED>
To: CENSORED
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: base64

BASE64-CONTENT-STRING

base64 decoded and shortened content

<p dir="ltr">Nein, ihr sammelt keine Daten... ihr doch nicht.<br>
&#13;Noch eine unangeforderte Email und Anzeige ist da! <br>
&#13;<br>
&#13;---&nbsp; <br>
&#13;Gru&#223;&nbsp; <br>
&#13;CENSORED</p>
<div class="quote">am 29.11.2018 13:15, Newsletter | DEMOCRACY &lt;CENSORED&gt; schrieb:<br type='attribution'><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>Newsletter 12 | DEMOCRACY</title>
  <meta name="format-detection" content="telephone=no" />
</head>

<body style="-webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: 'HelveticaNeue', Arial, sans-serif; font-size: 14px; font-weight: lighter; line-height: 1.3; margin: 0; padding: 0;">
  <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="bodyTable" style="border-collapse: collapse; height: 100% !important; width: 100% !important; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: 'HelveticaNeue', Arial, sans-serif; font-size: 14px; font-weight: lighter; line-height: 1.3; margin: 0; padding: 0;">
    <tr>
      <td align="left" valign="top" style="border-collapse: collapse; font-weight: normal; vertical-align: top; padding: 0.1em 0.5em;">
        <table border="0" cellpadding="0" cellspacing="0" width="100%" id="emailContainer" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
          <tr>
            <td align="left" valign="top" style="border-collapse: collapse; font-weight: normal; vertical-align: top; padding: 0.1em 0.5em;">
            
  <!-- DEMOCRACY inside double table wrapper -->
  
  <p class="anrede" style="max-width: 35rem; margin-top: 2em;">
    Liebe/r CENSORED,
  </p>

  <p style="max-width: 35rem; margin-top: 2em;">  
  es ist wieder soweit: <b>Zeit für ein paar Monatsnachrichten von ihrem Lieblingsprojekt</b> - der DEMOCRACY App. Seit dem MVP Release ist einiges passiert, was wir für Sie in den folgenden Zeilen ein wenig zusammengefasst haben.
</p>
  
HTML CONTENT OF ORIGINAL MESSAGE IN HERE

<style type="text/css">
body { margin: 0 !important; padding: 0 !important; }
img { display:block; border: 0 none !important; height: auto !important; line-height: 100% !important; outline: none !important; text-decoration: none !important; }
.ExternalClass { width: 100% !important; }
.ExternalClass { line-height: 100% !important; }
img { -ms-interpolation-mode: bicubic !important; }
body { -webkit-text-size-adjust: 100% !important; }
body { -ms-text-size-adjust: 100% !important; }
body { font-family: "HelveticaNeue", Arial, sans-serif !important; font-size: 14px !important; font-weight: lighter !important; line-height: 1.3 !important; }
</style>
</body>
</html></blockquote></div>

Notes:

The HTML does not contain then <p dir="ltr">..., but starts with the <table border="0" cellpadding="0"... which is the first tag in the body tag within the EMail

Version & Environment

Rev: [db4e50c7e0]

OS: [Chrome]

Configuration: [using Inline-View]

Originally created by @ulfgebhardt on GitHub (Nov 30, 2018). Original GitHub issue: https://github.com/cypht-org/cypht/issues/308 Originally assigned to: @jasonmunro on GitHub. ## 🐛 Bugreport <!-- Describe your issue in detail. Include screenshots if needed. Give us as much information as possible. --> This describes a very rare bug, which might be due to a problem in the sending client. If a `Person` replies to a HTML EMail, the response is in some cases not visible. ![image](https://user-images.githubusercontent.com/1238238/49286603-f48fb600-f49a-11e8-8cc1-1e6a1bbb1b9a.png) If you press reply, the Response becomes visible ![image](https://user-images.githubusercontent.com/1238238/49286686-3c164200-f49b-11e8-9ebc-eeeb255f1094.png) Raw Mail: ``` Return-Path: <CENSORED> X-Original-To: CENSORED Delivered-To: CENSORED Received: from CENSORED (CENSORED [CENSORED]) by CENSORED (Postfix) with ESMTPS id 427FFF761EDF for <CENSORED>; Thu, 29 Nov 2018 13:21:03 +0100 (CET) Authentication-Results: CENSORED; dkim=pass header.i=CENSORED; spf=neutral (sender IP is CENSORED) smtp.mailfrom=CENSORED smtp.helo=CENSORED Received-SPF: neutral (CENSORED: CENSORED is neither permitted nor denied by domain of CENSORED) client-ip=CENSORED; envelope-from=CENSORED; helo=CENSORED; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CENSORED; s=20140924; h=content-transfer-encoding:content-type:mime-version:to:from:subject:date:from; bh=CENSORED; b=CENSORED X-HalOne-Cookie: CENSORED X-HalOne-ID: CENSORED Received: from [CENSORED] (unknown [CENSORED]) by CENSORED (Halon) with ESMTPSA id CENSORED; Thu, 29 Nov 2018 12:21:02 +0000 (UTC) Date: Thu, 29 Nov 2018 13:20:59 +0100 Subject: =?UTF-8?Q?AW:_=F0=9F=93=B1_DEMOCRACY_News_#12_=E2=80=93_Wir_sind?= =?UTF-8?Q?_10.000,_Entwicklungsstand_und_Redesign?= From: "CENSORED" <CENSORED> To: CENSORED MIME-Version: 1.0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: base64 BASE64-CONTENT-STRING ``` base64 decoded and shortened content ``` <p dir="ltr">Nein, ihr sammelt keine Daten... ihr doch nicht.<br> &#13;Noch eine unangeforderte Email und Anzeige ist da! <br> &#13;<br> &#13;---&nbsp; <br> &#13;Gru&#223;&nbsp; <br> &#13;CENSORED</p> <div class="quote">am 29.11.2018 13:15, Newsletter | DEMOCRACY &lt;CENSORED&gt; schrieb:<br type='attribution'><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Newsletter 12 | DEMOCRACY</title> <meta name="format-detection" content="telephone=no" /> </head> <body style="-webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: 'HelveticaNeue', Arial, sans-serif; font-size: 14px; font-weight: lighter; line-height: 1.3; margin: 0; padding: 0;"> <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="bodyTable" style="border-collapse: collapse; height: 100% !important; width: 100% !important; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: 'HelveticaNeue', Arial, sans-serif; font-size: 14px; font-weight: lighter; line-height: 1.3; margin: 0; padding: 0;"> <tr> <td align="left" valign="top" style="border-collapse: collapse; font-weight: normal; vertical-align: top; padding: 0.1em 0.5em;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" id="emailContainer" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt;"> <tr> <td align="left" valign="top" style="border-collapse: collapse; font-weight: normal; vertical-align: top; padding: 0.1em 0.5em;"> <!-- DEMOCRACY inside double table wrapper --> <p class="anrede" style="max-width: 35rem; margin-top: 2em;"> Liebe/r CENSORED, </p> <p style="max-width: 35rem; margin-top: 2em;"> es ist wieder soweit: <b>Zeit für ein paar Monatsnachrichten von ihrem Lieblingsprojekt</b> - der DEMOCRACY App. Seit dem MVP Release ist einiges passiert, was wir für Sie in den folgenden Zeilen ein wenig zusammengefasst haben. </p> HTML CONTENT OF ORIGINAL MESSAGE IN HERE <style type="text/css"> body { margin: 0 !important; padding: 0 !important; } img { display:block; border: 0 none !important; height: auto !important; line-height: 100% !important; outline: none !important; text-decoration: none !important; } .ExternalClass { width: 100% !important; } .ExternalClass { line-height: 100% !important; } img { -ms-interpolation-mode: bicubic !important; } body { -webkit-text-size-adjust: 100% !important; } body { -ms-text-size-adjust: 100% !important; } body { font-family: "HelveticaNeue", Arial, sans-serif !important; font-size: 14px !important; font-weight: lighter !important; line-height: 1.3 !important; } </style> </body> </html></blockquote></div> ``` Notes: The HTML does not contain then `<p dir="ltr">...`, but starts with the `<table border="0" cellpadding="0"...` which is the first tag in the `body` tag within the EMail ### Version & Environment <!-- Paste Git-Commit ID or Tag-Name here --> Rev: [db4e50c7e0cb8b6913af9a03426d843fd1ad525c] <!-- Specify your OS and OS Version here if the issue is (most likely) platform dependent. --> OS: [Chrome] Configuration: [using Inline-View]
kerem 2026-02-25 21:34:36 +03:00
  • closed this issue
  • added the
    imap
    core
    labels
Author
Owner

@jasonmunro commented on GitHub (Nov 30, 2018):

@ulfgebhardt could you either send me or post the full raw E-mail so I can drop it in a maildir and run a local test? Thanks!

<!-- gh-comment-id:443257233 --> @jasonmunro commented on GitHub (Nov 30, 2018): @ulfgebhardt could you either send me or post the full raw E-mail so I can drop it in a maildir and run a local test? Thanks!
Author
Owner

@ulfgebhardt commented on GitHub (Nov 30, 2018):

I am afraid that i cannot give you this specific email, since the author is complaining about how we did not respect his privacy by sending him a newsletter :(. Therefore i would not like to share this specific email with you - just in case some test goes wrong and he receives an email, hell will break lose.

I will try to recreate the issue myself tho and provide the appropriate data once i successfully did that.

Thank you for developing this awesome software <3

<!-- gh-comment-id:443324889 --> @ulfgebhardt commented on GitHub (Nov 30, 2018): I am afraid that i cannot give you this specific email, since the author is complaining about how we did not respect his privacy by sending him a newsletter :(. Therefore i would not like to share this specific email with you - just in case some test goes wrong and he receives an email, hell will break lose. I will try to recreate the issue myself tho and provide the appropriate data once i successfully did that. Thank you for developing this awesome software <3
Author
Owner

@jasonmunro commented on GitHub (Nov 30, 2018):

@ulfgebhardt no problem, I totally understand. I rigged up a test with what you posted and can reproduce, though I'm not sure how to fix it. HTMLPurifier is removing the content outside the html tags it would seem. What is really odd is that if I remove the closing body tag before filtering it - it works!

<!-- gh-comment-id:443331829 --> @jasonmunro commented on GitHub (Nov 30, 2018): @ulfgebhardt no problem, I totally understand. I rigged up a test with what you posted and can reproduce, though I'm not sure how to fix it. HTMLPurifier is removing the content outside the html tags it would seem. What is really odd is that if I remove the closing body tag before filtering it - it works!
Author
Owner

@ulfgebhardt commented on GitHub (Dec 1, 2018):

Text version displaying Text:
image

HTML version missing Text:
image

Reply to HTML using HTML Editor - no Text either:
image

I set the client to HTML EMails for this Test. If you reply to the HTML-Version of the EMail and you use HTML as EMail format the original Message is never displayed

Steps i used to reproduce this:

  1. Set client to HTML EMail
  2. Find HTML EMail containing a whole HTML Document
  3. Copy the whole body
  4. Compose a new EMail
  5. Use Source-Tool
  6. Paste HTML Body into source
  7. Write something above the source you just pasted
  8. Send -> Reproduced

This is not a major Issue - This occurred with someone using a broken EMail-Client as it seems.
I am just reporting this in case you find an easy way to fix it. It is not a problem for me.

If the EMail contains HTML only and the EMail Client is set to HTML the Response can not be displayed in any way.

If you don't want to fix this/can't due to Security Limitations etc. feel free to close this. Just a report what I found ;-).

<3

<!-- gh-comment-id:443434907 --> @ulfgebhardt commented on GitHub (Dec 1, 2018): Text version displaying Text: ![image](https://user-images.githubusercontent.com/1238238/49329896-84f6f500-f586-11e8-8e01-de5b04ba3963.png) HTML version missing Text: ![image](https://user-images.githubusercontent.com/1238238/49329906-bec7fb80-f586-11e8-8b18-c7bde5497255.png) Reply to HTML using HTML Editor - no Text either: ![image](https://user-images.githubusercontent.com/1238238/49329960-a2788e80-f587-11e8-9470-768ac63cdfbc.png) I set the client to HTML EMails for this Test. If you reply to the HTML-Version of the EMail and you use HTML as EMail format the original Message is never displayed Steps i used to reproduce this: 1. Set client to HTML EMail 2. Find HTML EMail containing a whole HTML Document 3. Copy the whole body 4. Compose a new EMail 5. Use Source-Tool 6. Paste HTML Body into source 7. Write something above the source you just pasted 8. Send -> Reproduced This is not a major Issue - This occurred with someone using a broken EMail-Client as it seems. I am just reporting this in case you find an easy way to fix it. It is not a problem for me. If the EMail contains HTML only and the EMail Client is set to HTML the Response can not be displayed in any way. If you don't want to fix this/can't due to Security Limitations etc. feel free to close this. Just a report what I found ;-). <3
Author
Owner

@jasonmunro commented on GitHub (Dec 1, 2018):

Did some more testing on this (and while I was at it made it easier to rig up manual CLI tests). This behavior in HTMLPurifier is caused by content outside a body tag (regardless of an html tag). Interestingly if we remove the closing body tag - content outside the body is no longer discarded.

<?php

define('APP_PATH', dirname(dirname(__file__)).'/');
require sprintf('%s/scripts/load.php', APP_PATH);


/* foo is missing */
$str = 'foo<body>bar</body>';
out(format_msg_html($str));

/* foo is not missing */
$str = str_ireplace('</body>', '', $str);
out(format_msg_html($str));

/* html tags don't matter */
$str = 'foo<html>bar</html>';
out(format_msg_html($str));


?>

Output:

jason [ ~/cypht ]$ php ./scripts/test.php

string: bar


string: foobar


string: foobar

We don't want body or html tags in the final output anyway, and I don't see any reason not to remove the closing body tag to make this work better. Yes the format of the message HTML is obviously bad, but we should try to work around that as much as we can.

<!-- gh-comment-id:443454576 --> @jasonmunro commented on GitHub (Dec 1, 2018): Did some more testing on this (and while I was at it made it easier to rig up manual CLI tests). This behavior in HTMLPurifier is caused by content outside a body tag (regardless of an html tag). Interestingly if we remove the closing body tag - content outside the body is no longer discarded. ``` <?php define('APP_PATH', dirname(dirname(__file__)).'/'); require sprintf('%s/scripts/load.php', APP_PATH); /* foo is missing */ $str = 'foo<body>bar</body>'; out(format_msg_html($str)); /* foo is not missing */ $str = str_ireplace('</body>', '', $str); out(format_msg_html($str)); /* html tags don't matter */ $str = 'foo<html>bar</html>'; out(format_msg_html($str)); ?> ``` Output: ``` jason [ ~/cypht ]$ php ./scripts/test.php string: bar string: foobar string: foobar ``` We don't want body or html tags in the final output anyway, and I don't see any reason not to remove the closing body tag to make this work better. Yes the format of the message HTML is obviously bad, but we should try to work around that as much as we can.
Author
Owner

@jasonmunro commented on GitHub (Dec 1, 2018):

fix is pushed! :)

<!-- gh-comment-id:443455085 --> @jasonmunro commented on GitHub (Dec 1, 2018): fix is pushed! :)
Author
Owner

@ulfgebhardt commented on GitHub (Dec 2, 2018):

confirming fix

<!-- gh-comment-id:443515430 --> @ulfgebhardt commented on GitHub (Dec 2, 2018): confirming fix
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cypht#268
No description provided.