Index: openacs-4/packages/acs-templating/www/doc/demo/show.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/show.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-templating/www/doc/demo/show.tcl 11 Jul 2015 16:45:23 -0000 1.3 +++ openacs-4/packages/acs-templating/www/doc/demo/show.tcl 7 Aug 2017 23:48:02 -0000 1.4 @@ -1,28 +1,31 @@ ad_page_contract { - small demp + small demo source viewer @author unknown @creation-date unknown @cvs-id $Id$ } { - {file:token ""} + file:trim,notnull +} -validate { + valid_file -requires file { + if { [regexp {\.\.|^/} $file] } { + ad_complain "Only files within this directory may be shown." + } + set dir [file dirname [ad_conn file]] + if {![file readable $dir/$file] || [file isdirectory $dir/$file]} { + ad_complain "The specified file ist not readable" + } + } } -if { $file eq "" } { +# +# [ns_url2file [ns_conn url]] fails under request processor, since +# the request processor manges the provided url path. +# +set source [template::util::read_file $dir/$file] - set output "no file specified" - -} elseif { [regexp {\.\.|^/} $file] } { - - set output "Only files within this directory may be shown." - -} else { - - # [ns_url2file [ns_conn url]] fails under request processor ! - # the file for URL pkg/page may be in packages/pkg/www/page, not www/pkg/page - set dir [file dirname [ad_conn file]] - set text [ns_quotehtml [template::util::read_file $dir/$file]] - set output "
$text
" -} - -ns_return 200 text/html $output +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: