From 83852c4bca6320aa6c14b148b137430aec4c5260 Mon Sep 17 00:00:00 2001 From: aspect Date: Sat, 29 Apr 2017 11:04:10 +0000 Subject: [f9fe90d0fa]: more path normalization in TclNewFSPathObj --- generic/tclPathObj.c | 9 +++++++++ tests/fileSystem.test | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index 43a3c85..ea15937 100644 --- a/generic/tclPathObj.c +++ b/generic/tclPathObj.c @@ -1278,6 +1278,15 @@ TclNewFSPathObj( 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 diff --git a/tests/fileSystem.test b/tests/fileSystem.test index 1941936..4513fcb 100644 --- a/tests/fileSystem.test +++ b/tests/fileSystem.test @@ -367,6 +367,16 @@ test filesystem-1.51 {file normalisation .. beyond root (Bug 1379287)} { 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*]] { -- cgit v0.12