Skip to content

Commit cdd0724

Browse files
committed
Stricter handling of erroneous input when converting CP5022{0,1,2} text encoding
Don't allow escape sequences to start in the middle of a multibyte character. Also, don't silently pass through illegal bytes which appear where the 2nd byte of a multibyte character should be.
1 parent eec11c2 commit cdd0724

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

ext/mbstring/libmbfl/filters/mbfilter_cp5022x.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,20 +273,12 @@ mbfl_filt_conv_jis_ms_wchar(int c, mbfl_convert_filter *filter)
273273
w = 0;
274274
}
275275
if (w <= 0) {
276-
w = (c1 << 8) | c;
277-
w &= MBFL_WCSPLANE_MASK;
278-
w |= MBFL_WCSPLANE_JIS0212;
276+
w = (c1 << 8) | c | MBFL_WCSPLANE_JIS0212;
279277
}
280278
}
281279
CK((*filter->output_function)(w, filter->data));
282-
} else if (c == 0x1b) {
283-
filter->status += 2;
284-
} else if ((c >= 0 && c < 0x21) || c == 0x7f) { /* CTLs */
285-
CK((*filter->output_function)(c, filter->data));
286280
} else {
287-
w = (c1 << 8) | c;
288-
w &= MBFL_WCSGROUP_MASK;
289-
w |= MBFL_WCSGROUP_THROUGH;
281+
w = (c1 << 8) | c | MBFL_WCSGROUP_THROUGH;
290282
CK((*filter->output_function)(w, filter->data));
291283
}
292284
break;

0 commit comments

Comments
 (0)