Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d3aa224dd6170682be124e218ca6a94781408a5ff0d28a04215e7708664d592f
Ticket: 1bedc53c8cb878f0bf2a9b65c83b9e481f85fb47
synchronous [read] with -strictencoding does not produce an error on invalid input
User & Date: pooryorick on 2022-12-27 21:51:54
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    In trunk, test io-12.9, "ReadChars: multibyte chars split FAILED" does not result in an error when the test is changed so that the channel is configured with -strictencdoing 1:
    
    <code><verbatim>
    test io-12.9 {ReadChars: multibyte chars split} -body {
        set f [open $path(test1) w]
        fconfigure $f -translation binary
        puts -nonewline $f [string repeat a 9]\xC2
        close $f
        set f [open $path(test1)]
        fconfigure $f -strictencoding 1 -encoding utf-8 -buffersize 10
        set in [read $f]
        close $f
        scan [string index $in end] %c
    } -cleanup {
        catch {close $f}
    } -result 194
    </verbatim></code>
    
    This is incorrect.  An error should be returned.
    
    If a second [read] is added, it returns an error:
    
    <code><verbatim>
    test io-12.9 {ReadChars: multibyte chars split} -body {
        set f [open $path(test1) w]
        fconfigure $f -translation binary
        puts -nonewline $f [string repeat a 9]\xC2
        close $f
        set f [open $path(test1)]
        fconfigure $f -strictencoding 1 -encoding utf-8 -buffersize 10
        set in [read $f]
        read $f
        close $f
        scan [string index $in end] %c
    } -cleanup {
        catch {close $f}
    } -result 194
    </verbatim></code>
    
    
    This is also incorrect, because [read $chan] is defined to read all characters
    up until the end of the channel, implying that all data on the channel has been
    correctly read.
    
    The first [read] should return an error.
    
  5. is_private changed to: "0"
  6. login: "pooryorick"
  7. priority changed to: "5 Medium"
  8. resolution changed to: "None"
  9. severity changed to: "Severe"
  10. status changed to: "Open"
  11. submitter changed to: "pooryorick"
  12. subsystem changed to: "25. Channel System"
  13. title changed to:
    synchronous [read] with -strictencoding does not produce an error on invalid input
    
  14. type changed to: "Bug"