Skip to content

Commit 219fff3

Browse files
committed
Fix legacy text conversion filter for UTF7-IMAP
Make necessary updates to filter state before using CK macro.
1 parent 0a6ea5b commit 219fff3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ext/mbstring/libmbfl/filters/mbfilter_utf7imap.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,18 @@ int mbfl_filt_conv_utf7imap_wchar(int c, mbfl_convert_filter *filter)
140140
if (n < 0 || n > 63) {
141141
if (c == '-') {
142142
if (filter->status == 1) { /* "&-" -> "&" */
143+
filter->cache = filter->status = 0;
143144
CK((*filter->output_function)('&', filter->data));
144145
} else if (filter->cache) {
145146
/* Base64-encoded section ended abruptly, with partially encoded characters,
146147
* or it could be that it ended on the first half of a surrogate pair */
148+
filter->cache = filter->status = 0;
147149
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
148150
}
149151
} else { /* illegal character */
152+
filter->cache = filter->status = 0;
150153
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
151154
}
152-
filter->cache = filter->status = 0;
153155
return 0;
154156
}
155157
}

0 commit comments

Comments
 (0)