Skip to content

Commit bc18e32

Browse files
committed
Do not pass invalid ISO-8859-{3,6,7,8} characters through silently
mbstring has a bad habit of passing invalid characters through silently when converting to the same (or a "compatible") encoding. For example, if you give it an invalid JIS X 0208 kuten code encoded with SJIS, and try to convert that to EUC-JP, mbstring will just quietly re-encode the invalid code in the EUC-JP representation. At the same, some parts of the code (like `mb_check_encoding`) assume that invalid characters will be treated as... well, invalid. Let's unbreak things by actually catching errors and reporting them, instead of swallowing them.
1 parent 5c6b2a7 commit bc18e32

File tree

4 files changed

+0
-12
lines changed

4 files changed

+0
-12
lines changed

ext/mbstring/libmbfl/filters/mbfilter_iso8859_3.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ int mbfl_filt_conv_wchar_8859_3(int c, mbfl_convert_filter *filter)
121121
}
122122
n--;
123123
}
124-
if (s <= 0 && (c & ~MBFL_WCSPLANE_MASK) == MBFL_WCSPLANE_8859_3) {
125-
s = c & MBFL_WCSPLANE_MASK;
126-
}
127124
}
128125

129126
if (s >= 0) {

ext/mbstring/libmbfl/filters/mbfilter_iso8859_6.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ int mbfl_filt_conv_wchar_8859_6(int c, mbfl_convert_filter *filter)
121121
}
122122
n--;
123123
}
124-
if (s <= 0 && (c & ~MBFL_WCSPLANE_MASK) == MBFL_WCSPLANE_8859_6) {
125-
s = c & MBFL_WCSPLANE_MASK;
126-
}
127124
}
128125

129126
if (s >= 0) {

ext/mbstring/libmbfl/filters/mbfilter_iso8859_7.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ int mbfl_filt_conv_wchar_8859_7(int c, mbfl_convert_filter *filter)
121121
}
122122
n--;
123123
}
124-
if (s <= 0 && (c & ~MBFL_WCSPLANE_MASK) == MBFL_WCSPLANE_8859_7) {
125-
s = c & MBFL_WCSPLANE_MASK;
126-
}
127124
}
128125

129126
if (s >= 0) {

ext/mbstring/libmbfl/filters/mbfilter_iso8859_8.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ int mbfl_filt_conv_wchar_8859_8(int c, mbfl_convert_filter *filter)
120120
}
121121
n--;
122122
}
123-
if (s <= 0 && (c & ~MBFL_WCSPLANE_MASK) == MBFL_WCSPLANE_8859_8) {
124-
s = c & MBFL_WCSPLANE_MASK;
125-
}
126123
}
127124

128125
if (s >= 0) {

0 commit comments

Comments
 (0)