Should HTML be encoded before being stored in say, a database? Or is it normal practice to encode on its way out to the browser?
Should all my text based field lengt
The practice is to HTML encode before display.
If you are consistent about encoding before displaying, you have done a good bit of XSS
prevention.
You should save the original form in your database. This preserved the original and you may want to do other processing on that and not on the encoded version.