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 -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl 9 Dec 2020 15:07:47 -0000 1.1.2.1 +++ openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl 10 Dec 2020 14:00:41 -0000 1.1.2.2 @@ -12,22 +12,23 @@ ad__sanitize_filename { Tests that sanitizing a filename works as expected. } { - set str "A;\\ <<<*>CoOO/etc/passwdl# \"\u001f:: f__?ilename \u0000" + aa_section "Sanitized string without an extension" + set str "A;\\ <<<ß*>CoOO/etc/passwdl# \"\u001f:: f__?ilename \u0000" # Our test string is poisonous enough that this log command # would fail... # aa_log "Checking against '$str'" - aa_equals "Basic sanitizing" [ad_sanitize_filename $str] "A CoOOetcpasswdl# f__ilename " - aa_equals "Collapsing spaces" [ad_sanitize_filename -collapse_spaces $str] "A-CoOOetcpasswdl#-f__ilename-" - aa_equals "Collapsing spaces with a custom separator" [ad_sanitize_filename -replace_with _ -collapse_spaces $str] "A_CoOOetcpasswdl#_f__ilename_" - aa_equals "Collapsing spaces with a custom separator, to lower case" [ad_sanitize_filename -tolower -replace_with _ -collapse_spaces $str] [string tolower "A_CoOOetcpasswdl#_f__ilename_"] + aa_equals "Basic sanitizing" [ad_sanitize_filename $str] "A ßCoOOetcpasswdl# f__ilename " + aa_equals "Collapsing spaces" [ad_sanitize_filename -collapse_spaces $str] "A-ßCoOOetcpasswdl#-f__ilename-" + aa_equals "Collapsing spaces with a custom separator" [ad_sanitize_filename -replace_with _ -collapse_spaces $str] "A_ßCoOOetcpasswdl#_f__ilename_" + aa_equals "Collapsing spaces with a custom separator, to lower case" [ad_sanitize_filename -tolower -replace_with _ -collapse_spaces $str] [string tolower "A_ßCoOOetcpasswdl#_f__ilename_"] aa_true "Sanitizing to an existing filename without resolving throws an error" [catch { ad_sanitize_filename \ -tolower \ -replace_with _ \ -collapse_spaces \ -no_resolve \ - -existing_names {a_coooetcpasswdl#_f__ilename_} \ + -existing_names {a_ßcoooetcpasswdl#_f__ilename_} \ $str }] aa_false "Sanitizing without resolving does not throw an error with an empty list fo existing names" [catch { @@ -44,9 +45,43 @@ -tolower \ -replace_with _ \ -collapse_spaces \ - -existing_names {a_coooetcpasswdl#_f__ilename_} \ + -existing_names {a_ßcoooetcpasswdl#_f__ilename_} \ $str] - aa_equals "Sanitizing to an existing filename with resolving is fine" $resolved [string tolower "A_CoOOetcpasswdl#_f__ilename_"]_2 + aa_equals "Sanitizing to an existing filename with resolving is fine" $resolved [string tolower "A_ßCoOOetcpasswdl#_f__ilename_"]_2 + + aa_section "Sanitized string containing an extension" + set str "A;\\ <<<ß*>CoOO/etc/passwdl# \"\u001f:: f__?ilename \u0000.extension" + aa_equals "Basic sanitizing" [ad_sanitize_filename $str] "A ßCoOOetcpasswdl# f__ilename .extension" + aa_equals "Collapsing spaces" [ad_sanitize_filename -collapse_spaces $str] "A-ßCoOOetcpasswdl#-f__ilename-.extension" + aa_equals "Collapsing spaces with a custom separator" [ad_sanitize_filename -replace_with _ -collapse_spaces $str] "A_ßCoOOetcpasswdl#_f__ilename_.extension" + aa_equals "Collapsing spaces with a custom separator, to lower case" [ad_sanitize_filename -tolower -replace_with _ -collapse_spaces $str] [string tolower "A_ßCoOOetcpasswdl#_f__ilename_.extension"] + + aa_true "Sanitizing to an existing filename without resolving throws an error" [catch { + ad_sanitize_filename \ + -tolower \ + -replace_with _ \ + -collapse_spaces \ + -no_resolve \ + -existing_names {a_ßcoooetcpasswdl#_f__ilename_.extension} \ + $str + }] + aa_false "Sanitizing without resolving does not throw an error with an empty list fo existing names" [catch { + ad_sanitize_filename \ + -tolower \ + -replace_with _ \ + -collapse_spaces \ + -no_resolve \ + -existing_names {} \ + $str + }] + + set resolved [ad_sanitize_filename \ + -tolower \ + -replace_with _ \ + -collapse_spaces \ + -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 } # Local variables: