I'm attaching a patch that I believe fixes the problem.  It turns out,
it wasn't just the attribute vs value comparison: the order/insert logic
was incorrect too.

-Kevin
# HG changeset patch
# User Kevin McCarthy <[email protected]>
# Date 1457844777 28800
#      Sat Mar 12 20:52:57 2016 -0800
# Node ID 1cac8af98965c0b8c788d515b60e2d04b562dddd
# Parent  bd0e695f627ea12e67a7f54894c503cb6a29b040
Fix RFC2231 continuation join order.  (closes #3811) (closes #3741)

The function generating a list of parts to join had incorrect sorting
logic.  It was comparing values, not attributes.  Additionally, the
order logic wasn't correct.

Thanks to TAKAHASHI Tamotsu for pointing out the value vs attribute
comparison bug.

diff --git a/rfc2231.c b/rfc2231.c
--- a/rfc2231.c
+++ b/rfc2231.c
@@ -234,29 +234,29 @@
  * Primary sorting key: attribute
  * Secondary sorting key: index
  */
 
 static void rfc2231_list_insert (struct rfc2231_parameter **list,
                                 struct rfc2231_parameter *par)
 {
   struct rfc2231_parameter **last = list;
-  struct rfc2231_parameter *p = *list, *q;
+  struct rfc2231_parameter *p = *list;
   int c;
-  
+
   while (p)
   {
+    c = strcmp (par->attribute, p->attribute);
+    if ((c < 0) || (c == 0 && par->index <= p->index))
+      break;
+
     last = &p->next;
-    q = p; p = p->next;
+    p = p->next;
+  }
 
-    c = strcmp (par->value, q->value);
-    if ((c > 0) || (c == 0 && par->index >= q->index))
-      break;
-  }
-  
   par->next = p;
   *last = par;
 }
 
 /* process continuation parameters */
 
 static void rfc2231_join_continuations (PARAMETER **head,
                                        struct rfc2231_parameter *par)

Reply via email to