summaryrefslogtreecommitdiffstats
path: root/tests/io.test
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2023-04-18 22:00:10 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2023-04-18 22:00:10 (GMT)
commitdf0ddd7b9b44266ea375ae17eec07ebb21c1157c (patch)
tree14fb529c9ad38f41449807c4bd8ab31ef2aa8cc2 /tests/io.test
parentfdaffbc402070f4c96bf0bd3ec6398bf582a49af (diff)
downloadtcl-df0ddd7b9b44266ea375ae17eec07ebb21c1157c.zip
tcl-df0ddd7b9b44266ea375ae17eec07ebb21c1157c.tar.gz
tcl-df0ddd7b9b44266ea375ae17eec07ebb21c1157c.tar.bz2
Fix for [25cdcb7e8fb381fb]: Incomplete utf-8 sequence followed by eofchar
results in failed assertion.
Diffstat (limited to 'tests/io.test')
-rw-r--r--tests/io.test34
1 files changed, 30 insertions, 4 deletions
diff --git a/tests/io.test b/tests/io.test
index 3ab09e8..dfa015f 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -9326,25 +9326,51 @@ test io-75.8.eoflater {invalid utf-8 encoding eof handling (-profile strict)} -s
set res {}
set fn [makeFile {} io-75.8]
set f [open $fn w+]
+ # This also configures the channel encoding profile as strict.
fconfigure $f -encoding binary
# \x81 is invalid in utf-8. -eofchar is not detected, because it comes later.
- puts -nonewline $f A\x81\x1A
+ puts -nonewline $f A\x81\x81\x1A
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar \x1A \
-translation lf -profile strict
} -body {
- after 1
set status [catch {read $f} cres copts]
lappend res $status
lappend res [eof $f]
chan configure $f -encoding iso8859-1
- lappend res [read $f]
+ lappend res [read $f 1]
+ chan configure $f -encoding utf-8
+ catch {read $f 1} cres
+ lappend res $cres
close $f
set res
} -cleanup {
removeFile io-75.8
-} -result "1 0 \x81"
+} -match glob -result "1 0 \x81 {error reading \"*\":\
+ invalid or incomplete multibyte or wide character}"
+
+
+test io-strict-multibyte-eof {
+ incomplete utf-8 sequence immediately prior to eof character
+
+ See issue 25cdcb7e8fb381fb
+} -setup {
+ set res {}
+ set chan [file tempfile];
+ fconfigure $chan -encoding binary
+ puts -nonewline $chan \x81\x1A
+ flush $chan
+ seek $chan 0
+ chan configure $chan -encoding utf-8 -profile strict
+} -body {
+ set status [catch {read $chan 1} cres]
+ lappend res $status $cres
+} -cleanup {
+ close $chan
+ unset res
+} -match glob -result {1 {error reading "*":\
+ invalid or incomplete multibyte or wide character}}
test io-75.9 {unrepresentable character write passes and is replaced by ?} -setup {
set fn [makeFile {} io-75.9]