]> granicus.if.org Git - php/commitdiff
- MFH for multiple To: lines
authorDerick Rethans <derick@php.net>
Wed, 27 Mar 2002 20:39:27 +0000 (20:39 +0000)
committerDerick Rethans <derick@php.net>
Wed, 27 Mar 2002 20:39:27 +0000 (20:39 +0000)
ext/mailparse/rfc2045.c

index 0cd002f2acdaa43b69c5691890e20173f58f17f6..8459ea4e589f127741738f6f2cd7227890d6e1f8 100755 (executable)
@@ -758,7 +758,33 @@ static void do_header(struct rfc2045 *p)
                        val++;
                        while(isspace(*val))
                                val++;
-                       add_assoc_string(p->headerhash, t, val, 1);
+
+                       if (strcmp(t, "to") == 0 || strcmp(t, "cc") == 0) {
+                               /* join multiple To: or Cc: lines together, so that
+                                * those addresses are not silently ignored by scripts
+                                * that do not parse headers manually */
+                               zval **existing = NULL;
+
+                               if (SUCCESS == zend_hash_find(Z_ARRVAL_P(p->headerhash), t, strlen(t)+1, (void**)&existing)) {
+                                       int newlen;
+                                       char *newstr;
+
+                                       newlen = strlen(val) + Z_STRLEN_PP(existing) + 3;
+                                       newstr = emalloc(newlen);
+                                      
+                                       strcpy(newstr, Z_STRVAL_PP(existing));
+                                       strcat(newstr, ", ");
+                                       strcat(newstr, val);
+
+                                       add_assoc_string(p->headerhash, t, newstr, 0);
+
+                               } else {
+                                       add_assoc_string(p->headerhash, t, val, 1);
+                               }
+                       } else {
+                               add_assoc_string(p->headerhash, t, val, 1);
+                       }
+
                }
                if (strcmp(t, "mime-version") == 0)
                {