Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 6b4d964d14fa152fedad9af59a2d8ab23877de3a
Ticket: 3185609fffffffffffffffffffffffffffffffff
File normalization corner case of ... broken with -DUNICODE
User & Date: apnadkarni on 2011-02-18 08:38:41
Changes

  1. assignee changed to: "vincentdarley"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Ran into the following corner case as a result of a typo - if a path component contains "..." or (more than two dots), the normalized string is corrupted.
    (bug is WINDOWS specific)
    
    tkcon session:
    
    (tcl) 49 % pwd
    C:/Documents and Settings/ashok/My Documents/src/twapi-exp/twapi/tcl
    (tcl) 50 % file normalize [file join [pwd] ...]
    C:/Documents and Settings/ashok/My Documents/src/twapi-exp/twapi/tcltcl (more non-printable chars here)
    
    The problem was a broken calculation in TclpObjNormalizePath when UNICODE is defined. The patch to fix this is :
    
    *** tclWinFile.c.orig   2011-02-18 09:19:45.750000000 +0530
    --- tclWinFile.c        2011-02-18 13:45:03.750000000 +0530
    *************** TclpObjNormalizePath(
    *** 2778,2786 ****
                             * path segment and continue.
                             */
    
    !                       Tcl_DStringAppend(&dsNorm, (const char *)
    !                               ((WCHAR *)(nativePath + Tcl_DStringLength(&ds))
    !                               - dotLen), (int)(dotLen * sizeof(WCHAR)));
                        } else {
                            /*
                             * Normal path.
    --- 2778,2788 ----
                             * path segment and continue.
                             */
    
    !                       Tcl_DStringAppend(&dsNorm,
    !                                           ((const char *) nativePath) +
    !                                           Tcl_DStringLength(&ds) /* # bytes, not TCHARS */
    !                                           - (dotLen * sizeof(TCHAR)),
    !                                           (int)(dotLen * sizeof(WCHAR)));
                        } else {
                            /*
                             * Normal path.
    
    After patching, output is as follows :
    
    % file normalize [file join [pwd] ...]
    C:/Documents and Settings/ashok/My Documents/src/twapi-exp/twapi/tcl/...
    
    which matches Tcl 8.5 behavour.
    
    Note this behaviour has a separate issue - treatment of ... is different from Windows semantics. That is logged as a separate bug.
    
  4. foundin changed to: "obsolete: 8.6b1.1"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "apnadkarni"
  10. subsystem changed to: "36. Pathname Management"
  11. title changed to:
    File normalization corner case of ... broken with -DUNICODE
    
  12. type changed to: "Bug"