From e029f38f8dbb5b87911fd154c57d984cbeecbea0 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 19 Dec 2018 14:52:59 +0100 Subject: ignore tests using missing files add upstream patches for PHP 7.2 and 7.3 --- PHPINFO | 9 + REFLECTION | 2 +- mailparse-upstream.patch | 497 +++++++++++++++++++++++++++++++++++++++++++++++ php-pecl-mailparse.spec | 43 +++- 4 files changed, 546 insertions(+), 5 deletions(-) create mode 100644 PHPINFO create mode 100644 mailparse-upstream.patch diff --git a/PHPINFO b/PHPINFO new file mode 100644 index 0000000..05fcd9f --- /dev/null +++ b/PHPINFO @@ -0,0 +1,9 @@ + +mailparse + +mailparse support => enabled +Extension Version => 3.0.2 +Revision => $Revision$ + +Directive => Local Value => Master Value +mailparse.def_charset => us-ascii => us-ascii diff --git a/REFLECTION b/REFLECTION index ba888d8..d5bf49c 100644 --- a/REFLECTION +++ b/REFLECTION @@ -1,4 +1,4 @@ -Extension [ extension #104 mailparse version 3.0.2 ] { +Extension [ extension #112 mailparse version 3.0.2 ] { - INI { Entry [ mailparse.def_charset ] diff --git a/mailparse-upstream.patch b/mailparse-upstream.patch new file mode 100644 index 0000000..e0c52ea --- /dev/null +++ b/mailparse-upstream.patch @@ -0,0 +1,497 @@ +From 710cc7f02a0172bb1c6c249f2197414a70445f41 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Tue, 10 Jul 2018 15:53:10 +0200 +Subject: [PATCH] fix -Wformat warning + +--- + .gitignore | 2 ++ + mailparse.c | 2 +- + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/mailparse.c b/mailparse.c +index 229c361..0ec1b4e 100644 +--- a/mailparse.c ++++ b/mailparse.c +@@ -1518,7 +1518,7 @@ PHP_FUNCTION(mailparse_msg_get_part) + foundpart = php_mimepart_find_by_name(part, ZSTR_VAL(mimesection)); + + if (!foundpart) { +- php_error_docref(NULL, E_WARNING, "cannot find section %s in message", mimesection); ++ php_error_docref(NULL, E_WARNING, "cannot find section %s in message", ZSTR_VAL(mimesection)); + RETURN_FALSE; + } + foundpart->rsrc->gc.refcount++; +From 385763b215ca31b7677573a24156106e84e0b9f9 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Wed, 11 Jul 2018 08:11:09 +0200 +Subject: [PATCH] cleanup headers + +--- + README | 5 +++-- + config.m4 | 3 --- + config.w32 | 1 - + mailparse.c | 5 ++--- + php_mailparse.h | 5 ++--- + php_mailparse_mime.c | 5 ++--- + php_mailparse_mime.h | 5 ++--- + php_mailparse_rfc822.c | 5 ++--- + php_mailparse_rfc822.h | 4 ++-- + php_mailparse_rfc822.re | 5 ++--- + 10 files changed, 17 insertions(+), 26 deletions(-) + +diff --git a/README b/README +index bc43274..68aad8c 100644 +--- a/README ++++ b/README +@@ -1,6 +1,5 @@ +-mailparse library for PHP 4 ++mailparse library for PHP 7 + =========================== +-$Id$ + + Mailparse is an extension for parsing and working with email messages. + It can deal with rfc822 and rfc2045 (MIME) compliant messages. +@@ -8,6 +7,8 @@ Mailparse is stream based, which means that it does not keep in-memory + copies of the files it processes - so it is very resource efficient + when dealing with large messages. + ++Version 2.1.6 is for PHP 5 ++ + OO Syntax: + ============= + | + +----------------------------------------------------------------------+ + */ +-/* $Id$ */ + + #ifdef HAVE_CONFIG_H + #include "config.h" +diff --git a/php_mailparse.h b/php_mailparse.h +index 2df36db..11384f5 100644 +--- a/php_mailparse.h ++++ b/php_mailparse.h +@@ -1,8 +1,8 @@ + /* + +----------------------------------------------------------------------+ +- | PHP Version 5 | ++ | PHP Version 8 | + +----------------------------------------------------------------------+ +- | Copyright (c) 1997-2015 The PHP Group | ++ | Copyright (c) 1997-2018 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | +@@ -17,7 +17,6 @@ + | the support routines for this extension were based upon. | + +----------------------------------------------------------------------+ + */ +-/* $Id$ */ + + #ifndef PHP_MAILPARSE_H + #define PHP_MAILPARSE_H +diff --git a/php_mailparse_mime.c b/php_mailparse_mime.c +index 0cc7ff6..b22eabb 100644 +--- a/php_mailparse_mime.c ++++ b/php_mailparse_mime.c +@@ -1,8 +1,8 @@ + /* + +----------------------------------------------------------------------+ +- | PHP Version 5 | ++ | PHP Version 7 | + +----------------------------------------------------------------------+ +- | Copyright (c) 1997-2015 The PHP Group | ++ | Copyright (c) 1997-2018 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | +@@ -15,7 +15,6 @@ + | Author: Wez Furlong | + +----------------------------------------------------------------------+ + */ +-/* $Id$ */ + + #include "php.h" + #include "php_mailparse.h" +diff --git a/php_mailparse_mime.h b/php_mailparse_mime.h +index 18b9d80..a0ef70e 100644 +--- a/php_mailparse_mime.h ++++ b/php_mailparse_mime.h +@@ -1,8 +1,8 @@ + /* + +----------------------------------------------------------------------+ +- | PHP Version 5 | ++ | PHP Version 7 | + +----------------------------------------------------------------------+ +- | Copyright (c) 1997-2015 The PHP Group | ++ | Copyright (c) 1997-2018 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | +@@ -15,7 +15,6 @@ + | Author: Wez Furlong | + +----------------------------------------------------------------------+ + */ +-/* $Id$ */ + + #ifndef php_mailparse_mime_h + #define php_mailparse_mime_h +diff --git a/php_mailparse_rfc822.c b/php_mailparse_rfc822.c +index b6f965e..2cd4ec7 100644 +--- a/php_mailparse_rfc822.c ++++ b/php_mailparse_rfc822.c +@@ -2,9 +2,9 @@ + #line 1 "/home/vagrant/src/pecl-mail-mailparse/php_mailparse_rfc822.re" + /* + +----------------------------------------------------------------------+ +- | PHP Version 5 | ++ | PHP Version 7 | + +----------------------------------------------------------------------+ +- | Copyright (c) 1997-2015 The PHP Group | ++ | Copyright (c) 1997-2018 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | +@@ -17,7 +17,6 @@ + | Author: Wez Furlong | + +----------------------------------------------------------------------+ + */ +-/* $Id$ */ + + #include "php.h" + #include "php_mailparse.h" +diff --git a/php_mailparse_rfc822.h b/php_mailparse_rfc822.h +index 34b5532..b4bf8d6 100644 +--- a/php_mailparse_rfc822.h ++++ b/php_mailparse_rfc822.h +@@ -1,8 +1,8 @@ + /* + +----------------------------------------------------------------------+ +- | PHP Version 4 | ++ | PHP Version 5 | + +----------------------------------------------------------------------+ +- | Copyright (c) 1997-2015 The PHP Group | ++ | Copyright (c) 1997-2018 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | +diff --git a/php_mailparse_rfc822.re b/php_mailparse_rfc822.re +index 6562047..1903cc5 100644 +--- a/php_mailparse_rfc822.re ++++ b/php_mailparse_rfc822.re +@@ -1,8 +1,8 @@ + /* + +----------------------------------------------------------------------+ +- | PHP Version 5 | ++ | PHP Version 7 | + +----------------------------------------------------------------------+ +- | Copyright (c) 1997-2015 The PHP Group | ++ | Copyright (c) 1997-2018 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | +@@ -15,7 +15,6 @@ + | Author: Wez Furlong | + +----------------------------------------------------------------------+ + */ +-/* $Id$ */ + + #include "php.h" + #include "php_mailparse.h" +From 720ed5b77591922596564c414a655f3c7fcd6200 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Wed, 11 Jul 2018 11:26:35 +0200 +Subject: [PATCH] add dependency on mbstring extension + +--- + config.m4 | 3 +-- + mailparse.c | 11 +++++++++-- + 2 files changed, 10 insertions(+), 4 deletions(-) + +diff --git a/config.m4 b/config.m4 +index f3da8fc..d592726 100644 +--- a/config.m4 ++++ b/config.m4 +@@ -8,8 +8,7 @@ if test "$PHP_MAILPARSE" != "no"; then + enable_mbstring=yes + fi + PHP_NEW_EXTENSION(mailparse, mailparse.c php_mailparse_mime.c php_mailparse_rfc822.c, $ext_shared) +- ++ PHP_ADD_EXTENSION_DEP(mailparse, mbstring, true) + PHP_ADD_MAKEFILE_FRAGMENT +- + fi + +diff --git a/mailparse.c b/mailparse.c +index 8f60cb9..bf5be0f 100644 +--- a/mailparse.c ++++ b/mailparse.c +@@ -90,11 +90,18 @@ zend_function_entry mailparse_functions[] = { + + PHP_FE(mailparse_test, NULL) + +- {NULL, NULL, NULL} ++ PHP_FE_END ++}; ++ ++static const zend_module_dep mailparse_deps[] = { ++ ZEND_MOD_REQUIRED("mbstring") ++ ZEND_MOD_END + }; + + zend_module_entry mailparse_module_entry = { +- STANDARD_MODULE_HEADER, ++ STANDARD_MODULE_HEADER_EX, ++ NULL, ++ mailparse_deps, + "mailparse", + mailparse_functions, + PHP_MINIT(mailparse), +From 13c2c425e519b22660a03d566c35e76b3d4751dc Mon Sep 17 00:00:00 2001 +From: Jan-E +Date: Tue, 10 Jul 2018 17:42:24 +0200 +Subject: [PATCH] PHP 7.3 compatibility + +--- + mailparse.c | 13 +++++++++++++ + php_mailparse_mime.c | 9 +++++++++ + 2 files changed, 22 insertions(+) + +diff --git a/mailparse.c b/mailparse.c +index bf5be0f..f658d68 100644 +--- a/mailparse.c ++++ b/mailparse.c +@@ -984,12 +984,21 @@ PHP_FUNCTION(mailparse_stream_encode) + buf = emalloc(bufsize); + RETVAL_TRUE; + ++#if PHP_VERSION_ID >= 70300 ++ conv = mbfl_convert_filter_new(mbfl_no2encoding(mbfl_no_encoding_8bit), ++ mbfl_no2encoding(enc), ++ mailparse_stream_output, ++ mailparse_stream_flush, ++ deststream ++ ); ++#else + conv = mbfl_convert_filter_new(mbfl_no_encoding_8bit, + enc, + mailparse_stream_output, + mailparse_stream_flush, + deststream + ); ++#endif + + if (enc == mbfl_no_encoding_qprint) { + /* If the qp encoded section is going to be digitally signed, +@@ -1165,9 +1174,13 @@ PHP_FUNCTION(mailparse_msg_get_structure) + + mailparse_fetch_mimepart_resource(part, arg); + ++#if PHP_VERSION_ID >= 70300 ++ array_init(return_value); ++#else + if (array_init(return_value) == FAILURE) { + RETURN_FALSE; + } ++#endif + php_mimepart_enum_parts(part, &get_structure_callback, return_value); + } + /* }}} */ +diff --git a/php_mailparse_mime.c b/php_mailparse_mime.c +index b22eabb..8176c9d 100644 +--- a/php_mailparse_mime.c ++++ b/php_mailparse_mime.c +@@ -906,12 +906,21 @@ PHP_MAILPARSE_API void php_mimepart_decoder_prepare(php_mimepart *part, int do_d + if (from == mbfl_no_encoding_8bit || from == mbfl_no_encoding_7bit) { + part->extract_filter = NULL; + } else { ++#if PHP_VERSION_ID >= 70300 ++ part->extract_filter = mbfl_convert_filter_new( ++ mbfl_no2encoding(from), mbfl_no2encoding(mbfl_no_encoding_8bit), ++ filter_into_work_buffer, ++ NULL, ++ part ++ ); ++#else + part->extract_filter = mbfl_convert_filter_new( + from, mbfl_no_encoding_8bit, + filter_into_work_buffer, + NULL, + part + ); ++#endif + } + } + +From 4825a05d76b86d7c02bed0dbb9862e8357f6a3c2 Mon Sep 17 00:00:00 2001 +From: Jan-E +Date: Wed, 11 Jul 2018 00:40:59 +0200 +Subject: [PATCH] Move zend_string_init to the top of the block + +--- + mailparse.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/mailparse.c b/mailparse.c +index f658d68..2bcf0b6 100644 +--- a/mailparse.c ++++ b/mailparse.c +@@ -1432,9 +1432,10 @@ static void add_header_reference_to_zval(char *headerkey, zval *return_value, zv + static int mailparse_get_part_data(php_mimepart *part, zval *return_value) + { + zval headers, *tmpval; +- zend_string *hash_key; + off_t startpos, endpos, bodystart; + int nlines, nbodylines; ++ /* extract the address part of the content-id only */ ++ zend_string *hash_key = zend_string_init("content-id", sizeof("content-id") - 1, 0); + + array_init(return_value); + +@@ -1481,8 +1482,6 @@ static int mailparse_get_part_data(php_mimepart *part, zval *return_value) + if (part->boundary) + add_assoc_string(return_value, "content-boundary", part->boundary); + +- /* extract the address part of the content-id only */ +- hash_key = zend_string_init("content-id", sizeof("content-id") - 1, 0); + if ((tmpval = zend_hash_find(Z_ARRVAL_P(&headers), hash_key)) != NULL) { + php_rfc822_tokenized_t *toks; + php_rfc822_addresses_t *addrs; +From 449215fd2bea7a99bfc1a435565eef5191604c00 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Wed, 11 Jul 2018 11:43:58 +0200 +Subject: [PATCH] use proper macro + +--- + mailparse.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mailparse.c b/mailparse.c +index 2bcf0b6..99b0538 100644 +--- a/mailparse.c ++++ b/mailparse.c +@@ -976,7 +976,7 @@ PHP_FUNCTION(mailparse_stream_encode) + if (enc == mbfl_no_encoding_invalid) { + zend_error(E_WARNING, "%s(): unknown encoding \"%s\"", + get_active_function_name(), +- encod->val ++ ZSTR_VAL(encod) + ); + RETURN_FALSE; + } +From 132cb492bf9078732883653fca714504a4f6daf3 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 12 Jul 2018 14:20:54 +0200 +Subject: [PATCH] simplify, array_init always succeed + +--- + mailparse.c | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/mailparse.c b/mailparse.c +index 99b0538..df321c1 100644 +--- a/mailparse.c ++++ b/mailparse.c +@@ -1174,13 +1174,7 @@ PHP_FUNCTION(mailparse_msg_get_structure) + + mailparse_fetch_mimepart_resource(part, arg); + +-#if PHP_VERSION_ID >= 70300 + array_init(return_value); +-#else +- if (array_init(return_value) == FAILURE) { +- RETURN_FALSE; +- } +-#endif + php_mimepart_enum_parts(part, &get_structure_callback, return_value); + } + /* }}} */ +From 7df6d614e79ebdb2bf75f4913450229b55e72078 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Wed, 19 Dec 2018 14:30:30 +0100 +Subject: [PATCH] fix segfault, thanks cmb + +--- + mailparse.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/mailparse.c b/mailparse.c +index df321c1..92b247c 100644 +--- a/mailparse.c ++++ b/mailparse.c +@@ -1417,7 +1417,6 @@ static void add_header_reference_to_zval(char *headerkey, zval *return_value, zv + hash_key = zend_string_init(headerkey, strlen(headerkey), 0); + if ((headerval = zend_hash_find(Z_ARRVAL_P(headers), hash_key)) != NULL) { + ZVAL_DUP(&newhdr, headerval); +- Z_SET_REFCOUNT_P(&newhdr, 1); + add_assoc_zval(return_value, headerkey, &newhdr); + } + zend_string_release(hash_key); +@@ -1434,7 +1433,7 @@ static int mailparse_get_part_data(php_mimepart *part, zval *return_value) + array_init(return_value); + + /* get headers for this section */ +- ZVAL_DUP(&headers, &part->headerhash); ++ ZVAL_COPY(&headers, &part->headerhash); + + add_assoc_zval(return_value, "headers", &headers); + +From bddcfcb2d3a263c17ac40b79b1479b4b15ecd607 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Tue, 10 Jul 2018 14:37:49 +0200 +Subject: [PATCH] skip m0001.txt as m0001.exp doesn't exist + +--- + tests/parse_test_messages.phpt | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/tests/parse_test_messages.phpt b/tests/parse_test_messages.phpt +index 48a0d05..c111bd1 100644 +--- a/tests/parse_test_messages.phpt ++++ b/tests/parse_test_messages.phpt +@@ -157,6 +157,9 @@ $skip_keys = array("headers", "ending-pos-body"); + + foreach ($messages as $name => $msgdata) { + $testname = $testdir . "/" . $msgdata["testfile"]; ++ if (!isset($msgdata["expectfile"])) { ++ continue; ++ } + $expectname = $testdir . "/" . $msgdata["expectfile"]; + + $use_wrapper = substr($testname, -3) == ".gz" ? $wrapper : ""; diff --git a/php-pecl-mailparse.spec b/php-pecl-mailparse.spec index 137f7eb..8b54e79 100644 --- a/php-pecl-mailparse.spec +++ b/php-pecl-mailparse.spec @@ -11,6 +11,10 @@ # # Please, preserve the changelog entries # + +# we don't want -z defs linker flag +%undefine _strict_symbol_defs_build + %if 0%{?scl:1} %global sub_prefix %{scl_prefix} %scl_package php-pecl-mailparse @@ -23,17 +27,23 @@ Summary: PHP PECL package for parsing and working with email messages Name: %{?sub_prefix}php-pecl-mailparse Version: 3.0.2 -Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 8%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} License: PHP URL: http://pecl.php.net/package/mailparse -Source0: http://pecl.php.net/get/mailparse-%{version}.tgz +Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz + +Patch0: %{pecl_name}-upstream.patch +BuildRequires: %{?dtsprefix}gcc BuildRequires: %{?scl_prefix}php-devel > 7 BuildRequires: %{?scl_prefix}php-pear # mbstring need for tests BuildRequires: %{?scl_prefix}php-mbstring # Required by phpize BuildRequires: autoconf, automake, libtool +#BuildRequires: gdb +#BuildRequires: php-debuginfo +#BuildRequires: php-debugsource Requires: %{?scl_prefix}php-mbstring%{?_isa} Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} @@ -65,6 +75,14 @@ Obsoletes: php70w-pecl-%{pecl_name} <= %{version} Obsoletes: php71u-pecl-%{pecl_name} <= %{version} Obsoletes: php71w-pecl-%{pecl_name} <= %{version} %endif +%if "%{php_version}" > "7.2" +Obsoletes: php72u-pecl-%{pecl_name} <= %{version} +Obsoletes: php72w-pecl-%{pecl_name} <= %{version} +%endif +%if "%{php_version}" > "7.3" +Obsoletes: php73u-pecl-%{pecl_name} <= %{version} +Obsoletes: php73w-pecl-%{pecl_name} <= %{version} +%endif %endif %if 0%{?fedora} < 20 && 0%{?rhel} < 7 @@ -92,6 +110,8 @@ sed -e 's/role="test"/role="src"/' \ -i package.xml cd NTS +%patch0 -p1 -b .upstream + extver=$(sed -n '/#define PHP_MAILPARSE_VERSION/{s/.* "//;s/".*$//;p}' php_mailparse.h) if test "x${extver}" != "x%{version}"; then : Error: Upstream version is ${extver}, expecting %{version}. @@ -113,6 +133,8 @@ cp -pr NTS ZTS %build +%{?dtsenable} + cd NTS %{_bindir}/phpize %configure --with-php-config=%{_bindir}/php-config @@ -127,6 +149,8 @@ make %{?_smp_mflags} %install +%{?dtsenable} + make -C NTS install INSTALL_ROOT=%{buildroot} # Drop in the bit of configuration install -Dpm 644 %{ini_name} %{buildroot}%{php_inidir}/%{ini_name} @@ -147,6 +171,11 @@ done %check +: ignore tests using missing files +rm ?TS/tests/011.phpt +rm ?TS/tests/bug001.phpt +rm ?TS/tests/parse_test_messages.phpt + : Minimal load test for NTS extension %{__php} --no-php-ini \ --define extension=mbstring.so \ @@ -160,7 +189,8 @@ NO_INTERACTION=1 \ %{__php} run-tests.php \ -n -q \ -d extension=mbstring.so \ - -d extension=$PWD/modules/%{pecl_name}.so + -d extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \ + --show-diff %if %{with_zts} : Minimal load test for ZTS extension @@ -176,7 +206,8 @@ NO_INTERACTION=1 \ php run-tests.php \ -n -q \ -d extension=mbstring.so \ - -d extension=$PWD/modules/%{pecl_name}.so + -d extension=%{buildroot}%{php_ztsextdir}/%{pecl_name}.so \ + --show-diff %endif @@ -215,6 +246,10 @@ fi %changelog +* Wed Jun 6 2018 Remi Collet - 3.0.2-8 +- ignore tests using missing files +- add upstream patches for PHP 7.2 and 7.3 + * Wed Dec 7 2016 Remi Collet - 3.0.2-1 - update to 3.0.2 -- cgit