summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2006-04-07 14:05:26 (GMT)
committerdgp <dgp@users.sourceforge.net>2006-04-07 14:05:26 (GMT)
commitf137e44fa1a2dd7603fba62d1b44c103379e2781 (patch)
tree7aca42ff6117dc5049cbc7b4c2d81fcf3ce9f4c8
parentff1aeed46091825a1a52b5f03a39cecde7fbcac9 (diff)
downloadtcl-f137e44fa1a2dd7603fba62d1b44c103379e2781.zip
tcl-f137e44fa1a2dd7603fba62d1b44c103379e2781.tar.gz
tcl-f137e44fa1a2dd7603fba62d1b44c103379e2781.tar.bz2
* generic/tclPathObj.c: Yet another revised fix for the [Bug 1379287]
* tests/fileSystem.test: family of path normalization bugs.
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclPathObj.c17
-rw-r--r--tests/fileSystem.test20
3 files changed, 37 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 2d4c114..2bcfcca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-04-07 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tclPathObj.c: Yet another revised fix for the [Bug 1379287]
+ * tests/fileSystem.test: family of path normalization bugs.
+
2006-04-06 Jeff Hobbs <jeffh@ActiveState.com>
* generic/tclRegexp.c (FinalizeRegexp): full reset data to
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index 161d7de..ba8d155 100644
--- a/generic/tclPathObj.c
+++ b/generic/tclPathObj.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclPathObj.c,v 1.54 2006/04/06 16:43:03 dgp Exp $
+ * RCS: @(#) $Id: tclPathObj.c,v 1.55 2006/04/07 14:05:29 dgp Exp $
*/
#include "tclInt.h"
@@ -213,13 +213,17 @@ TclFSNormalizeAbsolutePath(
/*
* Need to skip '.' in the path.
*/
+ int curLen;
if (retVal == NULL) {
CONST char *path = TclGetString(pathPtr);
- retVal = Tcl_NewStringObj(path, dirSep - path
- + (dirSep == path));
+ retVal = Tcl_NewStringObj(path, dirSep - path);
Tcl_IncrRefCount(retVal);
}
+ Tcl_GetStringFromObj(retVal, &curLen);
+ if (curLen == 0) {
+ Tcl_AppendToObj(retVal, dirSep, 1);
+ }
dirSep += 2;
oldDirSep = dirSep;
if (dirSep[0] != 0 && dirSep[1] == '.') {
@@ -238,10 +242,13 @@ TclFSNormalizeAbsolutePath(
if (retVal == NULL) {
CONST char *path = TclGetString(pathPtr);
- retVal = Tcl_NewStringObj(path, dirSep - path
- + (dirSep == path));
+ retVal = Tcl_NewStringObj(path, dirSep - path);
Tcl_IncrRefCount(retVal);
}
+ Tcl_GetStringFromObj(retVal, &curLen);
+ if (curLen == 0) {
+ Tcl_AppendToObj(retVal, dirSep, 1);
+ }
if (!first || (tclPlatform == TCL_PLATFORM_UNIX)) {
link = Tcl_FSLink(retVal, NULL, 0);
if (link != NULL) {
diff --git a/tests/fileSystem.test b/tests/fileSystem.test
index 39e02c4..87e5e26 100644
--- a/tests/fileSystem.test
+++ b/tests/fileSystem.test
@@ -473,6 +473,26 @@ test filesystem-1.50 {file normalisation .. beyond root (Bug 1379287)} {
set res "ok"
}
} {ok}
+test filesystem-1.51 {file normalisation .. beyond root (Bug 1379287)} {
+ set a [file norm /../..]
+ set b [file norm /]
+
+ if {![string equal $a $b]} {
+ set res "Paths should be equal: $a , $b"
+ } else {
+ set res "ok"
+ }
+} {ok}
+test filesystem-1.51.1 {file normalisation .. beyond root (Bug 1379287)} {
+ set a [file norm /../../]
+ set b [file norm /]
+
+ if {![string equal $a $b]} {
+ set res "Paths should be equal: $a , $b"
+ } else {
+ set res "ok"
+ }
+} {ok}
test filesystem-2.0 {new native path} {unix} {
foreach f [lsort [glob -nocomplain /usr/bin/c*]] {