From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,61438484cfede653,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.42.246.3 with SMTP id lw3mr11267932icb.0.1320345805985; Thu, 03 Nov 2011 11:43:25 -0700 (PDT) Path: p6ni67341pbn.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!news.szn.dk!pnx.dk!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Date: Thu, 03 Nov 2011 19:43:24 +0100 From: =?ISO-8859-1?Q?Thomas_L=F8cke?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110905 Thunderbird/3.1.13 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Patch suggestion for a bug in the GNATCOLL-Email-Utils package Message-ID: <4eb2e0cc$0$290$14726298@news.sunsite.dk> Organization: SunSITE.dk - Supporting Open source NNTP-Posting-Host: 77.234.175.34 X-Trace: news.sunsite.dk DXC=DYIf0RiT>FKKJ1ZiZQ]7SLYSB=nbEKnkKdCdCeJ7VQcL3ZOKe3?:>XAcAE?;m5ccYCXohdXkZjmRFRHQnQi<3=;L X-Complaints-To: staff@sunsite.dk Xref: news2.google.com comp.lang.ada:14295 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Date: 2011-11-03T19:43:24+01:00 List-Id: Hey all, I'm posting this here because I don't know how else to get in touch with the GNATColl developers. May I suggest a maillist like the one the AWS developers have? :o) When using the GNATCOLL-Email-Utils package, you run into an annoying problem when calling the Encode procedure on a non-header string. What happens is that the subsequent call to the Quoted_Printable_Encode procedure dumps its Block_Separator all over the string it is encoding, which obviously is a bad thing. The Block_Separator is a constant: Block_Separator : constant String := " "; So you end up with an encoded string full of more or less random spaces. I wrote this small patch to "fix" it: --- ../../gnatlib/src/gnatcoll-email-utils.adb 2011-10-06 12:57:50.351259291 +0100 +++ gnatcoll-email-utils.adb 2011-11-03 14:57:07.000904069 +0000 @@ -1163,14 +1163,22 @@ for S in Str'Range loop if Needs_Quoting (Str (S)) then if Start /= -1 then - Append (Str (Start .. S - 1), Splittable => True); + if Header then + Append (Str (Start .. S - 1), Splittable => True); + else + Append (Result, Str (Start .. S - 1)); + end if; Start := -1; end if; declare Q : constant String := Quote (Str (S)); begin - Append (Q, Splittable => False); + if Header then + Append (Q, Splittable => False); + else + Append (Result, Q); + end if; Start := S + 1; end; @@ -1182,10 +1190,14 @@ end loop; if Start /= -1 then - Append (Str (Start .. Str'Last), Splittable => True); + if Header then + Append (Str (Start .. Str'Last), Splittable => True); + else + Append (Result, Str (Start .. Str'Last)); + end if; end if; - if Current_Len /= 0 then + if Current_Len /= 0 and then Header then Append (Result, Block_Suffix); end if; end Quoted_Printable_Encode; I'm not certain that my solution to the problem is the right one, but it solves the issue here and now for a working application. I did think about patching the Append procedure instead, but it seemed mighty complicated, so I chickened out on that one. Note that this bug does not show up when encoding very short strings. I haven't tested how long the string needs to be before it shows up, but I know for a fact that it happens consistenly with strings that are longer than 2000 characters, and that I've personally never experienced it with strings that are shorter than 22 characters. Please let me know if there's anything else I can do to help solve the issue. :o) -- Thomas L�cke Email: tl at ada-dk.org Web: http//:ada-dk.org http://identi.ca/thomaslocke