From 6ae93efff085e5d96d7e8e658ab64992e9e1191b Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Thu, 29 Jun 2023 11:09:29 +0000 Subject: Bug [6a3e2cb0f0] - invalid bytes in escape encodings --- generic/tclEncoding.c | 7 ++----- tests/encoding.test | 9 +++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 32878b0..f9f93fe 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -3961,11 +3961,8 @@ EscapeToUtfProc( if ((checked == dataPtr->numSubTables + 2) || (flags & TCL_ENCODING_END)) { if (!PROFILE_STRICT(flags)) { - /* - * Skip the unknown escape sequence. TODO - bug? - * May be replace with UNICODE_REPLACE_CHAR? - */ - + /* Unknown escape sequence */ + dst += Tcl_UniCharToUtf(UNICODE_REPLACE_CHAR, dst); src += longest; continue; } diff --git a/tests/encoding.test b/tests/encoding.test index c404eb0..4abc10e 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -1109,6 +1109,15 @@ test encoding-29.0 {get encoding nul terminator lengths} -constraints { [testencoding nullength ksc5601] } -result {1 2 4 2 2} +test encoding-bug-6a3e2cb0f0-1 {Bug [6a3e2cb0f0] - invalid bytes in escape encodings} -body { + encoding convertfrom -profile tcl8 iso2022-jp x\x1b\x7aaby +} -result x\uFFFDy +test encoding-bug-6a3e2cb0f0-2 {Bug [6a3e2cb0f0] - invalid bytes in escape encodings} -body { + encoding convertfrom -profile strict iso2022-jp x\x1b\x7aaby +} -returnCodes error -result {unexpected byte sequence starting at index 1: '\x1B'} +test encoding-bug-6a3e2cb0f0-3 {Bug [6a3e2cb0f0] - invalid bytes in escape encodings} -body { + encoding convertfrom -profile replace iso2022-jp x\x1b\x7aaby +} -result x\uFFFDy # cleanup namespace delete ::tcl::test::encoding -- cgit v0.12