From 9f2e0752a6f6ab07ff0b2411c9a945ba52804aff Mon Sep 17 00:00:00 2001 From: Kevin B Kenny Date: Fri, 22 Oct 2004 14:27:38 +0000 Subject: * library/clock.tcl: Fixed a typo where the fallback time zone became ::localtime instead of :localtime. Fixed a bug where time zone names containing hyphens could not be loaded. Thanks to Todd M. Helfter for finding these bugs. * tests/clock.test: Added regression test cases that covers both bugs. --- ChangeLog | 10 ++++++++++ library/clock.tcl | 8 ++++---- tests/clock.test | 24 +++++++++++++++++++++++- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 87ebc19..1b414ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-10-22 Kevin B. Kenny + + * library/clock.tcl: Fixed a typo where the fallback time zone + became ::localtime instead of :localtime. Fixed a bug where + time zone names containing hyphens could not be loaded. + * tests/clock.test: Added regression test cases that covers + both bugs. + Thanks to Todd M. Helfter for + finding these bugs. + 2004-10-22 Donal K. Fellows * generic/tclExecute.c (TclCompEvalObj, Tcl_ExprObj): diff --git a/library/clock.tcl b/library/clock.tcl index 95f7582..7fdc654 100644 --- a/library/clock.tcl +++ b/library/clock.tcl @@ -13,7 +13,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: clock.tcl,v 1.7 2004/10/21 03:53:10 kennykb Exp $ +# RCS: @(#) $Id: clock.tcl,v 1.8 2004/10/22 14:27:39 kennykb Exp $ # #---------------------------------------------------------------------- @@ -2927,7 +2927,7 @@ proc ::tcl::clock::GetSystemTimeZone {} { dict set TimeZoneBad $timezone [catch {SetupTimeZone $timezone}] } if { [dict get $TimeZoneBad $timezone] } { - return ::localtime + return :localtime } else { return $timezone } @@ -3466,7 +3466,7 @@ proc ::tcl::clock::LoadTimeZoneFile { fileName } { # this code is security sensitive. Make sure that the path name # cannot escape the given directory. - if { ![regexp {^[[:alpha:]_]+(?:/[[:alpha:]_]+)*$} $fileName] } { + if { ![regexp {^[[.-.][:alpha:]_]+(?:/[[.-.][:alpha:]_]+)*$} $fileName] } { return -code error \ -errorcode [list CLOCK badTimeZone $:fileName] \ "time zone \":$fileName\" not valid" @@ -3509,7 +3509,7 @@ proc ::tcl::clock::LoadZoneinfoFile { fileName } { # this code is security sensitive. Make sure that the path name # cannot escape the given directory. - if { ![regexp {^[[:alpha:]_]+(?:/[[:alpha:]_]+)*$} $fileName] } { + if { ![regexp {^[[.-.][:alpha:]_]+(?:/[[.-.][:alpha:]_]+)*$} $fileName] } { return -code error \ -errorcode [list CLOCK badTimeZone $:fileName] \ "time zone \":$fileName\" not valid" diff --git a/tests/clock.test b/tests/clock.test index dae01a2..f0752bc 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: clock.test,v 1.46 2004/10/04 15:30:25 kennykb Exp $ +# RCS: @(#) $Id: clock.test,v 1.47 2004/10/22 14:27:39 kennykb Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -35301,6 +35301,28 @@ test clock-43.1 {regression test - mktime returning -1} \ } \ -result {-1} +test clock-44.1 {regression test - time zone name containing hyphen } \ + -setup { + if { [info exists env(TZ)] } { + set oldTZ $env(TZ) + } + set env(TZ) US/East-Indiana + } \ + -body { + clock format 1098466496 -format %H:%M:%S%z -timezone US/East-Indiana + } \ + -cleanup { + if { [info exists oldTZ] } { + set env(TZ) $oldTZ + unset oldTZ + } else { + unset env(TZ) + } + } \ + -result {12:34:56-0500} + + + # cleanup namespace delete ::testClock -- cgit v0.12