spookztar wrote:Why is it necessary to escape all output, if all input is properly filtered and validated when recieved?
You might be escaping/filtering input to prevent SQL injection, but not escape/filter it to prevent against a cross site scripting attack. As such, it would be correct to escape/filter the output to prevent against a cross site scripting attack.
It might appear that this second step is unnecessary: why not just do the escaping/filtering all at once? The problem with that is that it assumes that the output is fixed to a particular format, but this might not be the case (or it might be the case now, but not later).