]> granicus.if.org Git - php/commitdiff
Fixed bug #52681 (mb_send_mail() appends an extra MIME-Version header).
authorAdam Harvey <aharvey@php.net>
Wed, 25 Aug 2010 06:07:22 +0000 (06:07 +0000)
committerAdam Harvey <aharvey@php.net>
Wed, 25 Aug 2010 06:07:22 +0000 (06:07 +0000)
ext/mbstring/mbstring.c
ext/mbstring/tests/bug52861.phpt [new file with mode: 0644]
ext/mbstring/tests/mb_send_mail01.phpt
ext/mbstring/tests/mb_send_mail02.phpt
ext/mbstring/tests/mb_send_mail03.phpt
ext/mbstring/tests/mb_send_mail04.phpt
ext/mbstring/tests/mb_send_mail05.phpt
ext/mbstring/tests/mb_send_mail06.phpt
ext/mbstring/tests/mb_send_mail07.phpt

index 4ca4545e970e46e68a85622c9c342447cf9f1d2c..9b01edbe2605b7be41b1ef6ad1be1f4e5f723950 100644 (file)
@@ -4025,7 +4025,7 @@ PHP_FUNCTION(mb_send_mail)
        }
 
        /* other headers */
-#define PHP_MBSTR_MAIL_MIME_HEADER1 "Mime-Version: 1.0"
+#define PHP_MBSTR_MAIL_MIME_HEADER1 "MIME-Version: 1.0"
 #define PHP_MBSTR_MAIL_MIME_HEADER2 "Content-Type: text/plain"
 #define PHP_MBSTR_MAIL_MIME_HEADER3 "; charset="
 #define PHP_MBSTR_MAIL_MIME_HEADER4 "Content-Transfer-Encoding: "
@@ -4038,8 +4038,10 @@ PHP_FUNCTION(mb_send_mail)
                }
        }
 
-       mbfl_memory_device_strncat(&device, PHP_MBSTR_MAIL_MIME_HEADER1, sizeof(PHP_MBSTR_MAIL_MIME_HEADER1) - 1);
-       mbfl_memory_device_strncat(&device, "\n", 1);
+       if (!zend_hash_exists(&ht_headers, "MIME-VERSION", sizeof("MIME-VERSION") - 1)) {
+               mbfl_memory_device_strncat(&device, PHP_MBSTR_MAIL_MIME_HEADER1, sizeof(PHP_MBSTR_MAIL_MIME_HEADER1) - 1);
+               mbfl_memory_device_strncat(&device, "\n", 1);
+       }
 
        if (!suppressed_hdrs.cnt_type) {
                mbfl_memory_device_strncat(&device, PHP_MBSTR_MAIL_MIME_HEADER2, sizeof(PHP_MBSTR_MAIL_MIME_HEADER2) - 1);
diff --git a/ext/mbstring/tests/bug52861.phpt b/ext/mbstring/tests/bug52861.phpt
new file mode 100644 (file)
index 0000000..085f3ba
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+Bug #52681 (mb_send_mail() appends an extra MIME-Version header)
+--SKIPIF--
+<?php
+if (!function_exists("mb_send_mail") || !mb_language("neutral")) {
+       die("skip mb_send_mail() not available");
+}
+?>
+--INI--
+sendmail_path=/bin/cat
+mail.add_x_header=off
+--FILE--
+<?php
+$to = 'example@example.com';
+$headers = 'MIME-Version: 2.0';
+
+mb_send_mail($to, mb_language(), "test", $headers);
+?>
+--EXPECTF--
+To: example@example.com
+Subject: %s
+MIME-Version: 2.0
+Content-Type: text/plain; charset=%s
+Content-Transfer-Encoding: %s
+
+%s
index 90cc3aa9c661a051880bec481658afefd4204608..28a401e3115bde41c52c80a72fb1f9e5f248af18 100644 (file)
@@ -25,14 +25,14 @@ if (mb_language("neutral")) {
 --EXPECTF--
 To: example@example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
 %s
 To: example@example.com
 Subject: test neutral
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: BASE64
 
index 81f2464d5b8ec6c854fc4fb74890736c7a67d9f4..af335ccc58bfd06bba396e2cabb9698fa2797484 100644 (file)
@@ -25,14 +25,14 @@ if (mb_language("japanese")) {
 --EXPECTF--
 To: example@example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
 %s
 To: example@example.com
 Subject: =?ISO-2022-JP?B?GyRCJUYlOSVIGyhCIEphcGFuZXNl?=
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=ISO-2022-JP
 Content-Transfer-Encoding: 7bit
 
index 1334fadd7050d94499aacdcf4b1931e5b6fd7176..23a988ffe1f98c71135593c8f5b520977c1f386e 100644 (file)
@@ -25,14 +25,14 @@ if (mb_language("english")) {
 --EXPECTF--
 To: example@example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
 %s
 To: example@example.com
 Subject: test English
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s-8859-1
 Content-Transfer-Encoding: 8bit
 
index 0dcc318cc094eb1955d4b04b87fed42e40df21c8..49bda090f5f35936dcb921becd44d28bcd93df3b 100644 (file)
@@ -25,14 +25,14 @@ if (mb_language("german")) {
 --EXPECTF--
 To: example@example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
 %s
 To: example@example.com
 Subject: =?ISO-8859-15?Q?Pr=FCfung=20German?=
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s-8859-15
 Content-Transfer-Encoding: 8bit
 
index a93fa791a134a70359acc444baa27328651239e9..1bbaaadcdad52b09efef8a9316c48380bc604028 100644 (file)
@@ -28,7 +28,7 @@ if (mb_language("simplified chinese")) {
 --EXPECTF--
 To: example@example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
@@ -36,7 +36,7 @@ Content-Transfer-Encoding: %s
 To: example@example.com
 Subject: =?HZ-GB-2312?B?fnsyYlFpfn0gU2ltcGxpZmllZCBD?=
  =?HZ-GB-2312?B?aGluZXNl?=
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=HZ-GB-2312
 Content-Transfer-Encoding: 7bit
 
index 9970340d55cf8a2fbbee2a98a39708075c239c99..4eb5492bc23ffd567a79d11fca1167f0abc7cde2 100644 (file)
@@ -28,14 +28,14 @@ if (mb_language("traditional chinese")) {
 --EXPECTF--
 To: example@example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
 %s
 To: example@example.com
 Subject: =?BIG5?B?tPrF5yBUcmFkaXRpb25hbCBDaGluZXNl?=
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=BIG5
 Content-Transfer-Encoding: 8bit
 
index afd9a0b15ca9937d46d6a14b259fc1dcea278364..42b91fa688fa4d8ae6c39a366228e74f1025d27a 100644 (file)
@@ -28,14 +28,14 @@ if (mb_language("korean")) {
 --EXPECTF--
 To: example@example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
 %s
 To: example@example.com
 Subject: =?ISO-2022-KR?B?GyQpQw5FVz06Ri4PIEtvcmVhbg8=?=
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=ISO-2022-KR
 Content-Transfer-Encoding: 7bit