Search The ForumSearch   RegisterRegister  LoginLogin

AfterLogic WebMail Lite 7

 AfterLogic Forum : AfterLogic WebMail Lite 7
Subject Topic: Quoted-Printable Has Invalid Control Chrs Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
isharemedical
Newbie
Newbie


Joined: 25 September 2019
Location: United States
Online Status: Offline
Posts: 7
Posted: 25 September 2019 at 8:25pm | IP Logged Quote isharemedical

We use Afterlogic Webmail as a front-end for one of our messaging applications. We are working toward certification to ONC 170.15(h)(2).

When I forward a message or use the "resend" option to send a message to the "Edge Testing Tool" (ETT) at testing@ttpedge.sitenv.org, the message includes an html attachment with the content-transfer-encoding set to "quoted-printable" (QP) that includes "=0A" characters (linefeed characters) in the lines of the html code. The validation report returned from the ETT indicates a failure in the validation of the QP due to the presence of these linefeed characters.

In RFC 2045, at https://tools.ietf.org/html/rfc2045#section-6.7, on p. 22, it says the following.

     Control characters other than TAB, or CR and LF as
     parts of CRLF pairs, must not appear. The same is true
     for octets with decimal values greater than 126. If
     found in incoming quoted-printable data by a decoder, a
     robust implementation might exclude them from the
     decoded data and warn the user that illegal characters
     were discovered.

The "CR and LF as parts of CRLF pairs" indicates that the presence of a linefeed character must be preceded by a carriage return (=0D=0A).

Below is an example of the HTML attachments created by Webmail upon sending a message.

     <!DOCTYPE html><html><head><meta http-equiv=3D"Content-Type" content=3D"t=
     ext/html; charset=3Dutf-8" /></head><body><div data-crea=3D"font-wrapper"=
      style=3D"font-family: Tahoma; font-size: 16px; direction: ltr"><div><div=
     >=0A<div data-crea=3D"font-wrapper" style=3D"font-family: Tahoma;font-siz=
     e: 16px;direction: ltr">test<br><br><div></div><br></div>=0A</div></div><=
     /div></body></html>

Is this a bug in Webmail or am I not understanding the RFC 2045 spec? Is this addressed in an updated version of Webmail? Also, I am looking for a way to change the default content-transfer-encoding to base64 to see if this will fix the issue with the ETT. I haven't found how to do this. Is this possible?
Back to Top View isharemedical's Profile Search for other posts by isharemedical
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 26 September 2019 at 7:02am | IP Logged Quote Alex

Hi,

Actually, it has never been an issue for any mail clients and nobody ever complained. You mean the problem's cause is that =0A is not preceded with =0D?

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
isharemedical
Newbie
Newbie


Joined: 25 September 2019
Location: United States
Online Status: Offline
Posts: 7
Posted: 26 September 2019 at 4:39pm | IP Logged Quote isharemedical

Alex,

Thank you for your reply. The answer is "yes". That appears to be the case. I actually did some testing by logging directly into our mail server via telnet on port 25 and issuing SMTP commands to send messages to testing@ttpedge.sitenv.org. I sent the following message, with the message ID set manually, but which is otherwise copied from the eml file I downloaded after using the Webmail UI to send a message. The validation report from the ETT indicated a failure in the text/html portion of the message with the error, 'Content-Transfer-Encoding = "quoted-printable", control characters other than TAB, or CR and LF as parts of CRLF pairs, MUST NOT appear'.

Note the two instances of "=0A" in the html portion of the message.

*******************

     250 2.1.0 Sender <m.mall.md@test.isharemedicalrecords.com> OK
     rcpt to:<testing@ttpedge.sitenv.org>
     250 2.1.5 Recipient <testing@ttpedge.sitenv.org> OK
     data
     354 Ok Send data ending with <CRLF>.<CRLF>
     Mime-Version: 1.0
     Date: Tue, 26 Sep 2019 19:22:00 +0000
     Content-Type: multipart/alternative;
      boundary="----=_Part_268_566199956.1569345055"
     Message-ID: <00000000000000000000000000000044@test.isharemedicalrecords.com>
     X-Mailer: AfterLogic webmail client
     Subject: test
     X-Priority: 3 (Normal)


     ------=_Part_268_566199956.1569345055
     Content-Type: text/plain; charset="utf-8"
     Content-Transfer-Encoding: quoted-printable

     test

     ------=_Part_268_566199956.1569345055
     Content-Type: text/html; charset="utf-8"
     Content-Transfer-Encoding: quoted-printable

     <!DOCTYPE html><html><head><meta http-equiv=3D"Content-Type" content=3D"t=
     ext/html; charset=3Dutf-8" /></head><body><div data-crea=3D"font-wrapper"=
      style=3D"font-family: Tahoma; font-size: 16px; direction: ltr"><div><div=
     >=0A<div data-crea=3D"font-wrapper" style=3D"font-family: Tahoma;font-siz=
     e: 16px;direction: ltr">test<br><br><div></div><br></div>=0A</div></div><=
     /div></body></html>

     ------=_Part_268_566199956.1569345055--
     .
     250 2.6.0 Message received

*******************

I then sent another message, changing the html portion to accommodate "=0D=0A" for the two instances that were previously "=0A" as follows. Everything else, except the message ID, is the same. In this case, the validation report was successful. The modified html portion of the message is below.

*******************

     <!DOCTYPE html><html><head><meta http-equiv=3D"Content-Type" content=3D"t=
     ext/html; charset=3Dutf-8" /></head><body><div data-crea=3D"font-wrapper"=
      style=3D"font-family: Tahoma; font-size: 16px; direction: ltr"><div><div=
     >=0D=0A<div data-crea=3D"font-wrapper" style=3D"font-family: Tahoma;font-=
     siz=
     e: 16px;direction: ltr">test<br><br><div></div><br></div>=0D=0A</div></di=
     v><=
     /div></body></html>

*******************
Back to Top View isharemedical's Profile Search for other posts by isharemedical
 
isharemedical
Newbie
Newbie


Joined: 25 September 2019
Location: United States
Online Status: Offline
Posts: 7
Posted: 26 September 2019 at 4:42pm | IP Logged Quote isharemedical

Alex,

One more thing. Is there a place to change the config to use base64 instead of quoted-printable for transfer-encoding?
Back to Top View isharemedical's Profile Search for other posts by isharemedical
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 27 September 2019 at 4:01am | IP Logged Quote Alex

Hi,

Try this to make the code produce CRLF instead of LF:

Open libraries/MailSo/Base/HtmlUtils.php file, locate ~871-872 lines in BuildHtml function:
          $sResult = \MailSo\Base\HtmlUtils::ClearTags($sResult);
          $sResult = \MailSo\Base\HtmlUtils::ClearBodyAndHtmlTag($sResult);

After that lines add the following ones for HTML part of message:
          $sResult = preg_replace("/\r\n/", "\n", $sResult);
          $sResult = preg_replace("/\n/", "\r\n", $sResult);

In the same file locate ~1068-1069 lines in ConvertHtmlToPlain function:
          $sText = preg_replace("/\n\\s+\n/", "\n", $sText);
          $sText = preg_replace("/[\n]{3,}/", "\n\n", $sText);

After that lines add the following ones:
          $sText = preg_replace("/\r\n/", "\n", $sText);
          $sText = preg_replace("/\n/", "\r\n", $sText);

Does it help?

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
isharemedical
Newbie
Newbie


Joined: 25 September 2019
Location: United States
Online Status: Offline
Posts: 7
Posted: 30 September 2019 at 8:53am | IP Logged Quote isharemedical

Alex,

Thank you once again for your reply. I made your suggested changes and, this time, I did get successful validation report results for the text/html portion of the message. However, I notice the "=0A" was replaced by a "native" CRLF instance. Was this the intent of these changes or were you anticipating the "=0A" would be replaced by "=0D=0A"? Below are the html portions from the message that was successful and from the message that had the "=0A" problem

HTML from message with successful validation:

     <!DOCTYPE html><html><head><meta http-equiv=3D"Content-Type" content=3D"t=
     ext/html; charset=3Dutf-8" /></head><body><div data-crea=3D"font-wrapper"=
      style=3D"font-family: Tahoma; font-size: 16px; direction: ltr"><div><div=
     >
     <div data-crea=3D"font-wrapper" style=3D"font-family: Tahoma;font-size: 1=
     6px;direction: ltr">test<br><br><div></div><br></div>
     </div></div></div></body></html>


HTML from message with "=0A" problem:

     <!DOCTYPE html><html><head><meta http-equiv=3D"Content-Type" content=3D"t=
     ext/html; charset=3Dutf-8" /></head><body><div data-crea=3D"font-wrapper"=
      style=3D"font-family: Tahoma; font-size: 16px; direction: ltr"><div><div=
     >=0A<div data-crea=3D"font-wrapper" style=3D"font-family: Tahoma;font-siz=
     e: 16px;direction: ltr">test<br><br><div></div><br></div>=0A</div></div><=
     /div></body></html>
Back to Top View isharemedical's Profile Search for other posts by isharemedical
 
isharemedical
Newbie
Newbie


Joined: 25 September 2019
Location: United States
Online Status: Offline
Posts: 7
Posted: 30 September 2019 at 9:00am | IP Logged Quote isharemedical

For further clarification, if you look at the places where there were previously instances of "=0A", there are now instances of native CRLF pairs which ends the lines without having = signs at the ends of the lines. Is this okay in quoted-printable, notwithstanding the fact that the validation report returned "successful"?
Back to Top View isharemedical's Profile Search for other posts by isharemedical
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 01 October 2019 at 2:37am | IP Logged Quote Alex

Yes, that's OK.

In QP, insert CRLF into the text, you can have =0D=0A or simply CRLF at the end of the line.

Not having '=' at the end of a line is important. If a line ends with "=CRLF", this CRLF will be removed by the decoder. Because in our case we want CRLF to stay intact, we must not prepend it with '='.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
isharemedical
Newbie
Newbie


Joined: 25 September 2019
Location: United States
Online Status: Offline
Posts: 7
Posted: 02 October 2019 at 6:09am | IP Logged Quote isharemedical

Alex,

Thank you very much. You have been very helpful.
Back to Top View isharemedical's Profile Search for other posts by isharemedical
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide