From 723c71df59bff241b11a707577f57ea81d1f4ecd Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 29 Oct 2024 19:59:32 +0100 Subject: [PATCH] =?UTF-8?q?closes=20gh-24=20(back-ported=20from=20regressi?= =?UTF-8?q?on=20fix=20for=20tcl-core=20[2c237beffbace823]):=20=20=20-=20us?= =?UTF-8?q?age=20of=20time=20zones=20`Etc/GMT=C2=B1n`=20is=20allowed=20now?= =?UTF-8?q?=20(were=20impossible=20previously=20due=20to=20incorrect=20pre?= =?UTF-8?q?vention=20of=20path=20escape=20for=20the=20tzdata=20directory);?= =?UTF-8?q?=20=20=20-=20test=20coverage=20(test=20clock-59.2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/clock.tcl | 4 ++-- tests/clock.test | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/clock.tcl b/lib/clock.tcl index 85df310..c39d599 100644 --- a/lib/clock.tcl +++ b/lib/clock.tcl @@ -1222,7 +1222,7 @@ proc ::tcl::clock::LoadTimeZoneFile { fileName } { # is security sensitive. Make sure that the path name cannot escape the # given directory. - if { ![regexp {^[[.-.][:alpha:]_]+(?:/[[.-.][:alpha:]_]+)*$} $fileName] } { + if { [regexp {^[/\\]|^[a-zA-Z]+:|(?:^|[/\\])\.\.} $fileName] } { return -code error \ -errorcode [list CLOCK badTimeZone $:fileName] \ "time zone \":$fileName\" not valid" @@ -1262,7 +1262,7 @@ proc ::tcl::clock::LoadZoneinfoFile { fileName } { # is security sensitive. Make sure that the path name cannot escape the # given directory. - if { ![regexp {^[[.-.][:alpha:]_]+(?:/[[.-.][:alpha:]_]+)*$} $fileName] } { + if { [regexp {^[/\\]|^[a-zA-Z]+:|(?:^|[/\\])\.\.} $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 0dc95e1..575f7f8 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -38201,6 +38201,23 @@ test clock-59.1 {military time zones} { join $trouble \n } {} +test clock-59.2 {correct time zone names, format and scan back, bug and regression [2c237beffbace823]} { + set result {} + foreach {base tz} { + 1700000000 "Etc/GMT-2" + 1700000000 "Etc/GMT+2" + 1301184000 "Europe/Kaliningrad" + 152632800 "Pacific/Chatham" + -765317964 "America/Paramaribo" + -2337928528 "Australia/Eucla" + } { + set v [clock format $base -timezone Etc/GMT-2 -format "%Y-%m-%d %H:%M:%S %Z"] + lappend result [expr {[set t [clock scan $v -format "%Y-%m-%d %H:%M:%S %Z"]] == $base ? 1 : "0 ($t != $base for $v)"}] + lappend result [expr {[set t [clock scan $v]] == $base ? 1 : "0 ($t != $base for $v)"}] + } + set result +} [lrepeat 12 1] + # case-insensitive matching of weekday and month names [Bug 1781282] test clock-60.1 {case insensitive weekday names} {