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 (required)
- message_ref (required)
- Returns:
- boolean
- Partial Call Graph (max 5 caller/called nodes):
- 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_filename] ad_log warning "They tried to sneak in invalid value '$value'" } return $resultXQL Not present: Generic, PostgreSQL, Oracle