template::data::validate::file (public)

 template::data::validate::file value_ref message_ref

Defined in packages/acs-templating/tcl/file-procs.tcl

Validate the value in the file widget. In particular: - make sure value is a list of 3 elements - ensure character cleanup has been performed - ensure tmpfile is safe

Parameters:
value_ref
message_ref
Returns:
boolean

Partial Call Graph (max 5 caller/called nodes):
%3 test_fs_upload_a_notmpfile fs_upload_a_notmpfile (test file-storage) template::data::validate::file template::data::validate::file test_fs_upload_a_notmpfile->template::data::validate::file test_template_widget_file template_widget_file (test acs-templating) test_template_widget_file->template::data::validate::file test_validate_file validate_file (test acs-templating) test_validate_file->template::data::validate::file _ _ (public) template::data::validate::file->_ ad_log ad_log (public) template::data::validate::file->ad_log security::safe_tmpfile_p security::safe_tmpfile_p (public) template::data::validate::file->security::safe_tmpfile_p

Testcases:
validate_file, template_widget_file, fs_upload_a_notmpfile
Source code:
    upvar 2 $message_ref message $value_ref value element element

    set result 1

    if { ![::string is list $value] ||
         [llength $value] != 3 ||
         "" in $value
     } {
        #
        # Value is not a list of 3 nonempty elements.
        #
        set result 0
    } elseif { [regexp {(\\| )} [lindex $value 0]] } {
        #
        # Backslashes and spaces were supposedly cleaned up during
        # file_transform.
        #
        set result 0
    } elseif { ![security::safe_tmpfile_p -must_exist [lindex $value 1]] } {
        #
        # The tmpfile is not safe
        #
        set result 0
    }

    if { !$result } {
        set message [_ acs-templating.Invalid_file]
        ad_log warning "They tried to sneak in invalid value '$value'"
    }

    return $result
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: