For the average web Dev my approach is plenty good enough.. It's funny because your approach still requires sanitizing
For the average web Dev my approach is plenty good enough.. It's funny because your approach still requires sanitizing
So, for example, you could have a data model of "plain text field", in that case you check that the input is a valid character string (so no undefined codepoints present and, for example, no syntax errors in the UTF-8 encoding if that is what you are using). Thus you can be sure that you have only characters strings in that column of your database. Then, if you want to output one of those strings to be displayed within an HTML page, you convert it from plain text to HTML (replacing "<" with "<", "&" with "&", and so on). That way there is no XSS possible, and also, any input the user makes is displayed back exactly as they entered it.
The idea is the same. You take user input and put it in a safe format. The programmers needs may be different.