From ca4e244cca3e93fb8689fe1cef85954da16ff989 Mon Sep 17 00:00:00 2001 From: pooryorick Date: Wed, 25 Jan 2023 02:52:24 +0000 Subject: Test TableFromUtfProc() with strict handling of encoding errors. --- generic/tclEncoding.c | 2 +- tests/encoding.test | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index d10d9ca..5ba7763 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -3199,7 +3199,7 @@ TableFromUtfProc( word = fromUnicode[(ch >> 8)][ch & 0xFF]; if ((word == 0) && (ch != 0)) { - if ((STOPONERROR) && (flags & TCL_ENCODING_CHAR_LIMIT)) { + if ((STOPONERROR)) { result = TCL_CONVERT_UNKNOWN; break; } diff --git a/tests/encoding.test b/tests/encoding.test index a1d129e..d9382e4 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -513,8 +513,11 @@ test encoding-17.10 {Utf32ToUtfProc} -body { encoding convertfrom -nocomplain utf-32 "\xFF\xFF\xFF\xFF" } -result \uFFFD -test encoding-18.1 {TableToUtfProc} { -} {} + +test encoding-18.1 {TableToUtfProc error on invalid input with -strict} -body { + list [catch {encoding convertto -strict jis0208 \\} res] $res +} -result {1 {unexpected character at index 0: 'U+00005C'}} + test encoding-19.1 {TableFromUtfProc} { } {} @@ -915,6 +918,7 @@ test encoding-29.0 {get encoding nul terminator lengths} -constraints { [testencoding nullength ksc5601] } -result {1 2 4 2 2} + # cleanup namespace delete ::tcl::test::encoding ::tcltest::cleanupTests -- cgit v0.12