News for hackers. Stuff that matters.
Re:Making Wrong Code Look Wrong by al_james on Monday August 22, 2011 @10:28AM (#2912550)
Yes, exactly, the meaning of 'safe string' depends on its context.

I personally believe that all code that is sensitive to escaping issues, should be escaped on output (or storage / sending to the database / whatever) by default unless you explicitly opt it out.

In our framework, we maintain 'already escaped' strings as a separate class, forcing the developer to acknowledge this fact. The HTML output layer escapes all strings unless they are instances of this safe class. Similarly for the SQL layer, all code gets quoted unless it was explicitly marked as 'safe'.

Re:Making Wrong Code Look Wrong by yesbabyyes on Monday August 22, 2011 @04:41PM (#2914035)
With eco templates, I output strings with <%=. To output unescaped strings such as templates, I must write <%-. This works for me.
Re:Making Wrong Code Look Wrong by eru on Monday August 22, 2011 @04:35PM (#2914009)
Do you treat SQL queries as strings in your code, or do you build something like an abstract syntax tree?
Re:Making Wrong Code Look Wrong by al_james on Tuesday August 23, 2011 @06:53PM (#2918703)
Build them using a syntax builder framework, but it is possible to pass raw SQL strings in in exceptional circumstances. Obviously, the developer needs to be totally aware of the risks of this. Not ideal, but needed to solve a couple of problems.