diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-04-11 08:23:44 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-04-11 08:23:44 (GMT) |
commit | 09e3a3c56b5d44c637c6ed0593257e51461e8861 (patch) | |
tree | dfc3b46957b430685b72d2a8c327fc6be0ea9aac | |
parent | c21a540c4153d8738dadc191a3b2d6516990c108 (diff) | |
download | tcl-09e3a3c56b5d44c637c6ed0593257e51461e8861.zip tcl-09e3a3c56b5d44c637c6ed0593257e51461e8861.tar.gz tcl-09e3a3c56b5d44c637c6ed0593257e51461e8861.tar.bz2 |
Fix [3118489] for Windows only: NUL in filenames. This allows various characters to be used in win32 filenames which are normally invalid, as described here: [http://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-specialchars]. The Cygwin shell can handle those same filenames as well. In other shells (cmd.exe/mSys) or on the Windows desktop the filenames will look strange, but that's all.
-rw-r--r-- | tests/cmdAH.test | 3 | ||||
-rw-r--r-- | win/tclWinFile.c | 8 |
2 files changed, 8 insertions, 3 deletions
diff --git a/tests/cmdAH.test b/tests/cmdAH.test index 39e9ece..80706b6 100644 --- a/tests/cmdAH.test +++ b/tests/cmdAH.test @@ -141,6 +141,9 @@ test cmdAH-2.6.2 {cd} -constraints {unix nonPortable} -setup { } -cleanup { cd $dir } -result {/} +test cmdAH-2.6.3 {Tcl_CdObjCmd, bug #3118489} -constraints win -returnCodes error -body { + cd .\0 +} -result "couldn't change working directory to \".\0\": no such file or directory" test cmdAH-2.7 {Tcl_ConcatObjCmd} { concat } {} diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 80d0915..c9b95a0 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -2897,7 +2897,7 @@ TclNativeCreateNativeRep( char *nativePathPtr, *str; Tcl_DString ds; Tcl_Obj *validPathPtr; - int len; + int len, i = 2; WCHAR *wp; if (TclFSCwdIsNative()) { @@ -2927,8 +2927,10 @@ TclNativeCreateNativeRep( Tcl_WinUtfToTChar(str, len, &ds); len = Tcl_DStringLength(&ds) + sizeof(WCHAR); wp = (WCHAR *) Tcl_DStringValue(&ds); - for (; *wp; ++wp) { - if (*wp=='/') { + for (i=sizeof(WCHAR); i<len; ++wp,i+=sizeof(WCHAR)) { + if ( (*wp < ' ') || wcschr(L"\"*<>|", *wp) ){ + *wp |= 0xF000; + }else if (*wp=='/') { *wp = '\\'; } } |