4 ms·
Not true. What you need is a type system. All data that comes from the user is of type UnescapedUserString. When the templating system sees this, it escapes
by jrockway 16y ago
Not true.
What you need is a type system. All data that comes from the user is of type UnescapedUserString. When the templating system sees this, it escapes it when written as HTML. Strings that you type into your program that you don't want to be escaped are of type EscapedString. Add some concatenation rules, and you're done.
If you were using Haskell, you wouldn't even need to change much code to do this, thanks to overloaded strings.