Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: fda265d789a79f1db6c7ddfce70cc63f2a39011605d355517e300b1ac4dc8a8a
Ticket: c61818e4c9b710bdf9f947c1a40563aeab85357a
Tcl_UtfPrev flaws
User & Date: dgp on 2020-04-08 19:45:49
Changes

  1. icomment:
    
    When we have strings that contain invalid byte sequences, callers of
    Tcl_UtfPrev already have bugs like this one.
    
    % interp alias {} bytes {} encoding convertfrom identity
    bytes
    % set demo [bytes "abc def\xE0\xA9ghi"]
    abc defà©ghi
    % string index $demo 10
    h
    % string is word [bytes \xA9]
    0
    % string index $demo [string wordstart $demo 10]
    e
    
    The answer ought to be "g". A second best answer might be "d".
    
    With the candidate fix, we get....
    
    % string index $demo [string wordstart $demo 10]
    e
    
    ...the same wrong result.
    
    I think our aim should be to get on a path to reach the day when we reject invalid
    byte sequences, so making Tcl handle them more correctly isn't a productive plan.
    
    More interested in any examples where the change leads to segfaults, etc.
    
  2. login: "dgp"
  3. mimetype: "text/plain"