Tcl pages
-
Always use Page Contracts:
All Tcl-implemented pages should use page contracts such as e.g.:ad_page_contract { ... purpose ... @author ... @creation-date ... } { object_id:naturalnum,notnull {verbose:boolean false} {color:word ""} }
-
Constrain arguments passed via query or form variables as strong as possible
All user provide content is potentially a security thread, since these values might lead to SQL-injection or XSS attacks. Therefore constrain the passed arguments as far as possible (see above), and validate the values further if necesary. -
Avoid putting in HTML in Tcl scripts
Try to make use of OpenACS Templating or http://your.openacs/doc/acs-templating/. If you can't avoid it try to isolate the HTML into a proc so editing the layout will be easier. -
Avoid Quoting Hell
If programmatic HTML-code generation is required, make sure that everything is quoted sufficiently and use the Tcl commandsubst
to improve readability:set href [export_vars -base admin/index -vars {foo bar] set html [subst { <a href="[ns_quotehtml $href]">Hello world</a> }]
-
Read the Tcl Style guide
This is the Tcl styleguide (PDF), try to apply relevant guidelines. In particular chapter 4,5 and 7.