1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
From a0d99d637281753f62a28842aad716352dc0e5a3 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@php.net>
Date: Tue, 30 May 2023 15:22:05 +0200
Subject: [PATCH] drop usage of removed mbfl APIs in PHP 8.3
---
mailparse.c | 19 ++++++++++---------
package.xml | 2 +-
php_mailparse_mime.c | 7 +++++--
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/mailparse.c b/mailparse.c
index dde0f18..315bfee 100644
--- a/mailparse.c
+++ b/mailparse.c
@@ -942,17 +942,15 @@ PHP_FUNCTION(mailparse_determine_best_xfer_encoding)
else if (++linelen > 200)
longline = 1;
}
- if (longline)
+ if (longline) {
bestenc = mbfl_no_encoding_qprint;
+ }
php_stream_rewind(stream);
- name = (char *)mbfl_no2preferred_mime_name(bestenc);
- if (name)
- {
+ name = mbfl_encoding_preferred_mime_name(mbfl_no2encoding(bestenc));
+ if (name) {
RETVAL_STRING(name);
- }
- else
- {
+ } else {
RETVAL_FALSE;
}
}
@@ -980,6 +978,7 @@ PHP_FUNCTION(mailparse_stream_encode)
char *buf;
size_t len;
size_t bufsize = 2048;
+ const mbfl_encoding *encoding;
enum mbfl_no_encoding enc;
mbfl_convert_filter *conv = NULL;
@@ -997,8 +996,10 @@ PHP_FUNCTION(mailparse_stream_encode)
php_stream_from_zval(srcstream, srcfile);
php_stream_from_zval(deststream, destfile);
- enc = mbfl_name2no_encoding(ZSTR_VAL(encod));
- if (enc == mbfl_no_encoding_invalid) {
+ encoding = mbfl_name2encoding(ZSTR_VAL(encod));
+ if (encoding) {
+ enc = encoding->no_encoding;
+ } else {
zend_error(E_WARNING, "%s(): unknown encoding \"%s\"",
get_active_function_name(),
ZSTR_VAL(encod)
diff --git a/php_mailparse_mime.c b/php_mailparse_mime.c
index fdf5862..49934f1 100644
--- a/php_mailparse_mime.c
+++ b/php_mailparse_mime.c
@@ -913,11 +913,14 @@ static int filter_into_work_buffer(int c, void *dat)
PHP_MAILPARSE_API void php_mimepart_decoder_prepare(php_mimepart *part, int do_decode, php_mimepart_extract_func_t decoder, void *ptr)
{
+ const mbfl_encoding *encoding;
enum mbfl_no_encoding from = mbfl_no_encoding_8bit;
if (do_decode && part->content_transfer_encoding) {
- from = mbfl_name2no_encoding(part->content_transfer_encoding);
- if (from == mbfl_no_encoding_invalid) {
+ encoding = mbfl_name2encoding(part->content_transfer_encoding);
+ if (encoding) {
+ from = encoding->no_encoding;
+ } else {
if (strcasecmp("binary", part->content_transfer_encoding) != 0) {
zend_error(E_WARNING, "%s(): mbstring doesn't know how to decode %s transfer encoding!",
get_active_function_name(),
From 59e040beacaa93626343bd440c4172bbc4aaef03 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@php.net>
Date: Tue, 30 May 2023 15:39:31 +0200
Subject: [PATCH] fix regression for PHP < 8.1
---
mailparse.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mailparse.c b/mailparse.c
index 315bfee..0f177ce 100644
--- a/mailparse.c
+++ b/mailparse.c
@@ -947,7 +947,11 @@ PHP_FUNCTION(mailparse_determine_best_xfer_encoding)
}
php_stream_rewind(stream);
- name = mbfl_encoding_preferred_mime_name(mbfl_no2encoding(bestenc));
+#if PHP_VERSION_ID < 80100
+ name = (char *)mbfl_no2preferred_mime_name(bestenc);
+#else
+ name = (char *)mbfl_encoding_preferred_mime_name(mbfl_no2encoding(bestenc));
+#endif
if (name) {
RETVAL_STRING(name);
} else {
|