Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 68731a59315435c25da437b21ffe510e5aae9c3a
Ticket: 2564363fffffffffffffffffffffffffffffffff
string equality testing does not cover encoding variants
User & Date: ferrieux on 2009-02-05 07:31:51
Changes

  1. icomment:
    It seems we are clearly violating advice given in (uncompiled) StringEqualCmd:
    
       * Remember to keep code here in some sync with the byte-compiled versions
       * in tclExecute.c (INST_STR_EQ, INST_STR_NEQ and INST_STR_CMP as well as
    
    Indeed the code near that comment tries two shimmer-less comparisons (ByteArray and String) before resorting to GetStringFromObj(). While the equivalent code in TEBC goes straight to it...
    One first idea would be to respect the above advice and stick to perfet eval-compile symmetry.
    However, shimmering is just a matter of speed and shouldn't affect the external EIAS semantics.
    So it might be better to remove that comment, since the lack of symmetry helps highlight a nasty bug.
    
    Now to the bug itself: here we have two pure-strep's (results from [encoding convertfrom identity]), which are two different UTF-8 strings. By calling [string length] on them we compute their String(unicode) intrep, which happen to be the same. Then when we call the non-compiled variant of [string equal] we hit the shimmer-less case, comparing on the (equal) unicode strings.
    
    So it seems we have a situation similar to non-canonical lists that would be compared on their List intreps.
    The solution would be to add similarly an "isCanonical" flag to the String intrep, and take that flag into account in the "fast-track" comparisons (ie forbid such comparisons on all but canonical Strings).
    
    More generally this would be the case of any intrep that is "fast-tracked" in one of the equality tests and fails to record deviation from canonicity.
    
    
  2. login: "ferrieux"
  3. mimetype: "text/plain"
  4. username: "ferrieux"