[SMARTY] assign_integer() convenience wrapper

Samuel Abels <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <1122484034.29230.18.camel@chef>
Hello,

I have a feature request: Often, it would be nice to ensure the type
safety of a variable before passing it into the template, to prevent
template authors from erroneously exposing unchecked values. For
example, insufficently checked (user manipulatable) integer values may
lead to possible Javascript injections if not casted before passed into
the template.
So to maintain safety, all such values need to be casted before being
assigned:

settype($_GET[id], 'integer');
$smarty->assign('id', $_GET[id]);

I found this to be a very common task and I believe it would be very
convenient if there were a method to do this.

$smarty->assign_integer('id', $_GET[id]);

(Of course I could just derive from Smarty and add a method myself, but
it may be a useful feature generally.)

-Samuel

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.