Check-in [27bac5b2c6]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[f9fe90d0fa]: more path normalization in TclNewFSPathObj
Timelines: family | ancestors | bug-f9fe90d0fa
Files: files | file ages | folders
SHA1: 27bac5b2c692775e4da90b60337a68fd9b9f3f94
User & Date: aspect 2017-04-29 11:04:10.585
References
2017-04-29
11:05 Ticket [f9fe90d0fa] Inconsistent handling of leading // status still Open with 3 other changes artifact: 36ecfc49e7 user: aspect
Context
2017-04-29
11:04
[f9fe90d0fa]: more path normalization in TclNewFSPathObj Leaf check-in: 27bac5b2c6 user: aspect tags: bug-f9fe90d0fa
2017-04-28
17:57
[f34cf83dd0] An optimization was being taken in a case where it produced the wrong result, failing t... check-in: e895b53905 user: dgp tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclPathObj.c.
1273
1274
1275
1276
1277
1278
1279









1280
1281
1282
1283
1284
1285
1286
    const char *addStrRep,
    int len)
{
    FsPath *fsPathPtr;
    Tcl_Obj *pathPtr;
    const char *p;
    int state = 0, count = 0;










    /* [Bug 2806250] - this is only a partial solution of the problem.
     * The PATHFLAGS != 0 representation assumes in many places that
     * the "tail" part stored in the normPathPtr field is itself a
     * relative path.  Strings that begin with "~" are not relative paths,
     * so we must prevent their storage in the normPathPtr field.
     *







>
>
>
>
>
>
>
>
>







1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
    const char *addStrRep,
    int len)
{
    FsPath *fsPathPtr;
    Tcl_Obj *pathPtr;
    const char *p;
    int state = 0, count = 0;

    /* if dirPtr is already tclFsPathType, its string representation
     * may not be canonical.  Try to use its normPathPtr in this case.
     */
    if (   (dirPtr->typePtr == &tclFsPathType)
	&& (PATHOBJ(dirPtr)->cwdPtr == NULL) 
	&& (PATHOBJ(dirPtr)->normPathPtr != NULL)  ) {
	dirPtr = PATHOBJ(dirPtr)->normPathPtr;
    }

    /* [Bug 2806250] - this is only a partial solution of the problem.
     * The PATHFLAGS != 0 representation assumes in many places that
     * the "tail" part stored in the normPathPtr field is itself a
     * relative path.  Strings that begin with "~" are not relative paths,
     * so we must prevent their storage in the normPathPtr field.
     *
Changes to tests/fileSystem.test.
363
364
365
366
367
368
369










370
371
372
373
374
375
376
} ok
test filesystem-1.51 {file normalisation .. beyond root (Bug 1379287)} {
    testPathEqual [file norm /../..] [file norm /]
} ok
test filesystem-1.51.1 {file normalisation .. beyond root (Bug 1379287)} {
    testPathEqual [file norm /../../] [file norm /]
} ok











test filesystem-2.0 {new native path} {unix} {
   foreach f [lsort [glob -nocomplain /usr/bin/c*]] {
       catch {file readlink $f}
   }
   # If we reach here we've succeeded. We used to crash above.
   return ok







>
>
>
>
>
>
>
>
>
>







363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
} ok
test filesystem-1.51 {file normalisation .. beyond root (Bug 1379287)} {
    testPathEqual [file norm /../..] [file norm /]
} ok
test filesystem-1.51.1 {file normalisation .. beyond root (Bug 1379287)} {
    testPathEqual [file norm /../../] [file norm /]
} ok
test filesystem-1.52 {bug f9f390d0fa: file join where strep is not canonical} -body {
    set x //foo
    file normalize $x
    file join $x bar
} -result /foo/bar
test filesystem-1.52.1 {bug f9f390d0fa: file join where strep is not canonical} -body {
    set x //foo
    file normalize $x
    file join $x
} -result /foo

test filesystem-2.0 {new native path} {unix} {
   foreach f [lsort [glob -nocomplain /usr/bin/c*]] {
       catch {file readlink $f}
   }
   # If we reach here we've succeeded. We used to crash above.
   return ok