comp.lang.ada
 help / color / mirror / Atom feed
* Patch suggestion for a bug in the GNATCOLL-Email-Utils package
@ 2011-11-03 18:43 Thomas Løcke
  2011-11-03 19:52 ` Jeffrey Carter
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Løcke @ 2011-11-03 18:43 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Patch suggestion for a bug in the GNATCOLL-Email-Utils package
  2011-11-03 18:43 Patch suggestion for a bug in the GNATCOLL-Email-Utils package Thomas Løcke
@ 2011-11-03 19:52 ` Jeffrey Carter
  2011-11-04 13:50   ` Thomas Løcke
  0 siblings, 1 reply; 3+ messages in thread
From: Jeffrey Carter @ 2011-11-03 19:52 UTC (permalink / raw)


On 11/03/2011 11:43 AM, Thomas L�cke wrote:
>
> 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)

You can send an e-mail to report@adacore.com.

-- 
Jeff Carter
"My mind is a raging torrent, flooded with rivulets of
thought, cascading into a waterfall of creative alternatives."
Blazing Saddles
89



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Patch suggestion for a bug in the GNATCOLL-Email-Utils package
  2011-11-03 19:52 ` Jeffrey Carter
@ 2011-11-04 13:50   ` Thomas Løcke
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Løcke @ 2011-11-04 13:50 UTC (permalink / raw)


On 11/03/2011 08:52 PM, Jeffrey Carter wrote:
>
> You can send an e-mail to report@adacore.com.
>


Thank you very much Jeffrey. I emailed the bug report to the suggested
address, and a few hours later I got a reply from them. Very nice!

:o)

-- 
Thomas L�cke

Email: tl at ada-dk.org
Web: http//:ada-dk.org
http://identi.ca/thomaslocke



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-11-04 13:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-03 18:43 Patch suggestion for a bug in the GNATCOLL-Email-Utils package Thomas Løcke
2011-11-03 19:52 ` Jeffrey Carter
2011-11-04 13:50   ` Thomas Løcke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox