bugGNU Mailutils - Bugs: bug #45867, invalid processing of folded...

 
 

bug #45867: invalid processing of folded strings in mu_string_unfold in library v2.2

Submitter:  Ivan Keberlein <ikeberlein>
Submitted:  Thu 03 Sep 2015 03:39:25 AM UTC
Votes: 1
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned to:  gray
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 05 Sep 2015 07:27:22 PM UTC, comment #1: 

mu_string_unfold is not expected to handle ASCII CR (\r) symbols.  All Mailutils functions assume that lines in multiline text are terminated with a single LF (\n) character.  The same applies to mu_string_unfold.

Your proposed modification will make the function work for your particular implementation, but will break its expected behaviour elsewhere.  Besides, it assumes that \r is always followed by \n, which might not always be the case.

The CRLF->LF translation is built-in into the Mailutils transport level.  If, for some reason, you need to process CRLF-terminated text, be sure
to translate it using the "CRLF" filter as shown in the example below (mailutils 2.99.x is assumed):

char *p
crlf_unfold (char *text)
{
  mu_stream_t flt;
  mu_stream_t input;
  size_t len;
  char *p = malloc (strlen (text)+1);

  mu_static_memory_stream_create (&input, text, strlen (text));
  mu_filter_create (&flt, input, "CRLF", MU_FILTER_DECODE, MU_STREAM_READ);
  mu_stream_unref (input);
  mu_stream_read (flt, p, sizeof (p), &len);
  p[len] = 0;
  int rc = mu_string_unfold (p, &len);
  mu_stream_destroy (&flt);
  if (rc)
    {
      free (p);
      p = NULL;
    }
  return p;
}


For more info on CRLF filter, refer to http://mailutils.org/wiki/CRLF_%28filter%29

Sergey Poznyakoff <gray>
Group administrator
Thu 03 Sep 2015 03:39:25 AM UTC, original submission:  

The function mu_string_unfold does not work as expected. In processed strings it leaves extra '\r' character.

For example, processing a string "this\r\n  string\r\n  was folded" the expected result should  be "this string was folded", but actual result is "this\r string\r was folded".

Test to check function mu_string_unfold is attached. Patch to fix  function mu_string_unfold is attached too.

Hope this helps.

Ivan Keberlein <ikeberlein>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #34800:  mu_string_unfold_test.c added by ikeberlein (638B - application/octet-stream)
file #34801:  fix_mu_string_unfold.patch added by ikeberlein (626B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gray (Posted a comment)
  • -email is unavailable- added by ikeberlein (Voted in favor of this item)
  • -email is unavailable- added by ikeberlein (Submitted the item)
  •  

    There is 1 vote so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-07-25 gray Open/ClosedOpen Closed
    2015-09-05 gray StatusNone Invalid
        Assigned toNone gray
    2015-09-03 ikeberlein Carbon-Copy- Added ikeberlein
    2015-09-03 ikeberlein Attached File- Added mu_string_unfold_test.c, #34800
        Attached File- Added fix_mu_string_unfold.patch, #34801

    Back to the top

    Powered by Savane 3.13-cf05.
    Corresponding source code