Commit bc18e32690 for php.net

commit bc18e326902eb29cd237f87b9f37457d39fe8059
Author: Alex Dowad <alexinbeijing@gmail.com>
Date:   Fri Oct 16 22:03:27 2020 +0200

    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.

diff --git a/ext/mbstring/libmbfl/filters/mbfilter_iso8859_3.c b/ext/mbstring/libmbfl/filters/mbfilter_iso8859_3.c
index 0c061055f8..5cd3bfce1d 100644
--- a/ext/mbstring/libmbfl/filters/mbfilter_iso8859_3.c
+++ b/ext/mbstring/libmbfl/filters/mbfilter_iso8859_3.c
@@ -121,9 +121,6 @@ int mbfl_filt_conv_wchar_8859_3(int c, mbfl_convert_filter *filter)
 			}
 			n--;
 		}
-		if (s <= 0 && (c & ~MBFL_WCSPLANE_MASK) == MBFL_WCSPLANE_8859_3) {
-			s = c & MBFL_WCSPLANE_MASK;
-		}
 	}

 	if (s >= 0) {
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_iso8859_6.c b/ext/mbstring/libmbfl/filters/mbfilter_iso8859_6.c
index ead2b49e0b..8b1fc4bbad 100644
--- a/ext/mbstring/libmbfl/filters/mbfilter_iso8859_6.c
+++ b/ext/mbstring/libmbfl/filters/mbfilter_iso8859_6.c
@@ -121,9 +121,6 @@ int mbfl_filt_conv_wchar_8859_6(int c, mbfl_convert_filter *filter)
 			}
 			n--;
 		}
-		if (s <= 0 && (c & ~MBFL_WCSPLANE_MASK) == MBFL_WCSPLANE_8859_6) {
-			s = c & MBFL_WCSPLANE_MASK;
-		}
 	}

 	if (s >= 0) {
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_iso8859_7.c b/ext/mbstring/libmbfl/filters/mbfilter_iso8859_7.c
index 63ae85e84e..e87ae0ec36 100644
--- a/ext/mbstring/libmbfl/filters/mbfilter_iso8859_7.c
+++ b/ext/mbstring/libmbfl/filters/mbfilter_iso8859_7.c
@@ -121,9 +121,6 @@ int mbfl_filt_conv_wchar_8859_7(int c, mbfl_convert_filter *filter)
 			}
 			n--;
 		}
-		if (s <= 0 && (c & ~MBFL_WCSPLANE_MASK) == MBFL_WCSPLANE_8859_7) {
-			s = c & MBFL_WCSPLANE_MASK;
-		}
 	}

 	if (s >= 0) {
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_iso8859_8.c b/ext/mbstring/libmbfl/filters/mbfilter_iso8859_8.c
index 36c967405b..3436d8d3ea 100644
--- a/ext/mbstring/libmbfl/filters/mbfilter_iso8859_8.c
+++ b/ext/mbstring/libmbfl/filters/mbfilter_iso8859_8.c
@@ -120,9 +120,6 @@ int mbfl_filt_conv_wchar_8859_8(int c, mbfl_convert_filter *filter)
 			}
 			n--;
 		}
-		if (s <= 0 && (c & ~MBFL_WCSPLANE_MASK) == MBFL_WCSPLANE_8859_8) {
-			s = c & MBFL_WCSPLANE_MASK;
-		}
 	}

 	if (s >= 0) {