Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -N -r1.189.2.154 -r1.189.2.155 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 7 Nov 2022 13:34:34 -0000 1.189.2.154 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 8 Nov 2022 09:55:39 -0000 1.189.2.155 @@ -2477,13 +2477,16 @@ # way confusion through replacement of deleted content # with new stuff is avoided. + set str_length [string length "${str}${replace_with}"] set number 2 foreach name $existing_names { - if { [regexp "${str}${replace_with}(\\d+)\$" $name match n] } { - # matches the foo-123 pattern - if { $n >= $number } { set number [expr {$n + 1}] } + if {[string range $name 0 $str_length-1] eq "${str}${replace_with}"} { + set n [string range $name $str_length end] + if {[string is integer -strict $n] && $n >= $number} { + set number [incr n] + } } } Index: openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/Attic/utilities-procs.tcl,v diff -u -N -r1.1.2.12 -r1.1.2.13 --- openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl 11 Oct 2022 09:04:58 -0000 1.1.2.12 +++ openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl 8 Nov 2022 09:55:40 -0000 1.1.2.13 @@ -82,6 +82,10 @@ -existing_names {a_ßcoooetcpasswdl#_f__ilename_.extension} \ $str] aa_equals "Sanitizing to an existing filename with resolving is fine" $resolved [string tolower "A_ßCoOOetcpasswdl#_f__ilename_.extension"]_2 + + aa_false "Sanitizing with not balanced parantheses in the filename does not throw an error" [catch { + aa_equals "Sanitizing to an existing filename with resolving is fine" [ad_sanitize_filename -existing_names {foo( foo(-3} "foo("] "foo(-4" + }] }