diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2025-06-09 16:55:39 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2025-06-09 16:55:39 (GMT) |
| commit | 62d918cae7eb113fa4233890c3e7259ccbdec7df (patch) | |
| tree | d35cb38636ca7cec2b2ed01571bdb99ac8f126f1 | |
| parent | 8ebcf55a9fb76e0832e586a20cdaa0f809e4859c (diff) | |
| download | tcl-62d918cae7eb113fa4233890c3e7259ccbdec7df.zip tcl-62d918cae7eb113fa4233890c3e7259ccbdec7df.tar.gz tcl-62d918cae7eb113fa4233890c3e7259ccbdec7df.tar.bz2 | |
Fix for [b876737a0b]: tcl::tm::path doesn't handle tilde expandcore-bug-b876737a0b
| -rw-r--r-- | library/tm.tcl | 28 | ||||
| -rw-r--r-- | unix/Makefile.in | 2 | ||||
| -rwxr-xr-x | unix/configure | 2 | ||||
| -rw-r--r-- | unix/configure.ac | 2 |
4 files changed, 21 insertions, 13 deletions
diff --git a/library/tm.tcl b/library/tm.tcl index ae3c6f4..fff871b 100644 --- a/library/tm.tcl +++ b/library/tm.tcl @@ -97,6 +97,11 @@ proc ::tcl::tm::add {args} { set newpaths $paths foreach p $args { + set pe $p + if {![interp issafe] && [catch {file tildeexpand $p} p]} { + # Paths relative to unresolvable home dirs are ignored + continue + } if {($p eq "") || ($p in $newpaths)} { # Ignore any path which is empty or already on the list. continue @@ -105,11 +110,11 @@ proc ::tcl::tm::add {args} { # Search for paths which are subdirectories of the new one. If there # are any then the new path violates the restriction about ancestors. - set pos [lsearch -glob $newpaths ${p}/*] + set pos [lsearch -glob $newpaths $p/*] # Cannot use "in", we need the position for the message. if {$pos >= 0} { return -code error \ - "$p is ancestor of existing module path [lindex $newpaths $pos]." + "$pe is ancestor of existing module path [lindex $newpaths $pos]." } # Now look for existing paths which are ancestors of the new one. This @@ -119,7 +124,7 @@ proc ::tcl::tm::add {args} { foreach ep $newpaths { if {[string match ${ep}/* $p]} { return -code error \ - "$p is subdirectory of existing module path $ep." + "$pe is subdirectory of existing module path $ep." } } @@ -143,6 +148,10 @@ proc ::tcl::tm::remove {args} { variable paths foreach p $args { + if {![interp issafe] && [catch {file tildeexpand $p} p]} { + # Paths relative to unresolvable home dirs are ignored + continue + } set pos [lsearch -exact $paths $p] if {$pos >= 0} { set paths [lreplace $paths $pos $pos] @@ -333,10 +342,7 @@ proc ::tcl::tm::Defaults {} { ] { if {![info exists env($ev)]} continue foreach p [split $env($ev) $::tcl_platform(pathSeparator)] { - # Paths relative to unresolvable home dirs are ignored - if {![catch {file tildeexpand $p} expanded_path]} { - path add $expanded_path - } + path add $p } } } @@ -359,14 +365,16 @@ proc ::tcl::tm::Defaults {} { proc ::tcl::tm::roots {paths} { regexp {^(\d+)\.(\d+)} [package provide tcl] - major minor foreach pa $paths { - set p [file join $pa tcl$major] + # Paths relative to unresolvable home dirs are ignored + if {[catch {file tildeexpand $pa} pa]} { + continue + } + set p [file join [file normalize $pa] tcl$major] for {set n $minor} {$n >= 0} {incr n -1} { set px [file join $p ${major}.${n}] - if {![interp issafe]} {set px [file normalize $px]} path add $px } set px [file join $p site-tcl] - if {![interp issafe]} {set px [file normalize $px]} path add $px } return diff --git a/unix/Makefile.in b/unix/Makefile.in index 9569b3b..8cebdd4 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -1097,7 +1097,7 @@ install-libraries: libraries done @if [ -n "$(TCL_MODULE_PATH)" -a -f $(TOP_DIR)/library/tm.tcl ] ; then \ echo "Customizing tcl module path"; \ - echo "if {![interp issafe]} { ::tcl::tm::roots [list $(TCL_MODULE_PATH)] }" >> \ + echo "if {![interp issafe]} {::tcl::tm::roots [split {$(TCL_MODULE_PATH)} :]}" >> \ "$(SCRIPT_INSTALL_DIR)/tm.tcl"; \ fi diff --git a/unix/configure b/unix/configure index 924d3a3..3c23360 100755 --- a/unix/configure +++ b/unix/configure @@ -11303,7 +11303,7 @@ if test "$FRAMEWORK_BUILD" = "1" ; then test -z "$TCL_PACKAGE_PATH" && \ TCL_PACKAGE_PATH="~/Library/Tcl:/Library/Tcl:~/Library/Frameworks:/Library/Frameworks" test -z "$TCL_MODULE_PATH" && \ - TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl" + TCL_MODULE_PATH="~/Library/Tcl:/Library/Tcl" elif test "$prefix/lib" != "$libdir"; then test -z "$TCL_PACKAGE_PATH" && TCL_PACKAGE_PATH="${libdir}:${prefix}/lib" else diff --git a/unix/configure.ac b/unix/configure.ac index d8adb4a..cd36358 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -869,7 +869,7 @@ if test "$FRAMEWORK_BUILD" = "1" ; then test -z "$TCL_PACKAGE_PATH" && \ TCL_PACKAGE_PATH="~/Library/Tcl:/Library/Tcl:~/Library/Frameworks:/Library/Frameworks" test -z "$TCL_MODULE_PATH" && \ - TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl" + TCL_MODULE_PATH="~/Library/Tcl:/Library/Tcl" elif test "$prefix/lib" != "$libdir"; then test -z "$TCL_PACKAGE_PATH" && TCL_PACKAGE_PATH="${libdir}:${prefix}/lib" else |
