Index: openacs-4/packages/acs-bootstrap-installer/tcl/test/00-proc-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-bootstrap-installer/tcl/test/Attic/00-proc-procs.tcl,v diff -u -r1.1.2.2 -r1.1.2.3 --- openacs-4/packages/acs-bootstrap-installer/tcl/test/00-proc-procs.tcl 15 Feb 2021 14:13:11 -0000 1.1.2.2 +++ openacs-4/packages/acs-bootstrap-installer/tcl/test/00-proc-procs.tcl 16 Feb 2021 02:31:33 -0000 1.1.2.3 @@ -13,15 +13,52 @@ aa_false "'file tail' works as expected without a tilde character" [catch { file tail $non_existing_user - } errmsg] + } errorMsg] set failure [catch { file tail $tilde_filename - } errmsg] - aa_true "'file tail' fails with a tilde character, revealing existing users! -> '$errmsg'" \ + } errorMsg] + aa_true "'file tail' raises an error with leading tilde character, revealing existing users! -> '$errorMsg'" \ $failure - aa_false "ad_file sanitizes the tilde character from the filename" [catch { + aa_false "ad_file raises no error with leading tilde character" [catch { ad_file tail $tilde_filename - } errmsg] + } errorMsg] + + set fresh_fn [ns_sha1 [clock seconds]] + set i 0 + + while {[file exists $fresh_fn-$i]} { incr i } + # touch the fresh file without tilde + close [open $fresh_fn-$i w] + aa_log "filename without tilde: $fresh_fn-$i [pwd]" + + aa_true "file exists $fresh_fn-$i" [file exists $fresh_fn-$i] + aa_true "ad_file exists $fresh_fn-$i" [ad_file exists $fresh_fn-$i] + + aa_false "file exists $fresh_fn-$i" [file exists ~$fresh_fn-$i] + aa_false "ad_file exists $fresh_fn-$i" [ad_file exists ~$fresh_fn-$i] + + aa_false "file tail ~$fresh_fn-$i" {[catch {file tail ~$fresh_fn-$i}] == 0} + aa_true "ad_file tail ~$fresh_fn-$i" {[ad_file tail ~$fresh_fn-$i] eq "./~$fresh_fn-$i"} + + file delete $fresh_fn-$i + + # + # now the same with an existing file with a leading tilde + # + set j $i + while {[file exists ~$fresh_fn-$j]} { incr j } + # touch the fresh file with tilde + close [open ./~$fresh_fn-$j w] + aa_log "filename with tilde: ~$fresh_fn-$j" + + aa_true "file exists ./~$fresh_fn-$j" [file exists ./~$fresh_fn-$j] + aa_true "ad_file exists ./~$fresh_fn-$j" [ad_file exists ./~$fresh_fn-$j] + aa_true "ad_file exists ~$fresh_fn-$j" [ad_file exists ~$fresh_fn-$j] + + aa_false "file tail ~$fresh_fn-$j" {[catch {file tail ~$fresh_fn-$j}] == 0} + aa_true "ad_file tail ~$fresh_fn-$j" {[ad_file tail ~$fresh_fn-$j] eq "./~$fresh_fn-$j"} + + file delete ./~$fresh_fn-$j }