Skip to content

Commit

Permalink
Test TableFromUtfProc() with strict handling of encoding errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
pooryorick committed Jan 25, 2023
1 parent ba635ae commit d29df9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion generic/tclEncoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 6 additions & 2 deletions tests/encoding.test
Original file line number Diff line number Diff line change
Expand Up @@ -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} {
} {}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d29df9d

Please sign in to comment.