javascript - Should I save in db - user input as html encode? -


we're having conflict coworkers on whether should htmlencode user input , save db ( vs saving straight forward is)

i find various answers says db should save plain(!) input.

why ? because db should know user length 1 in < , not 4 in &lt;

the html encoding should only made when outputting.

but:

having said , see stackoverflow not following rule.

when save question here @ , contains plain < show (obviously) &lt; in preview pane. when submit question : submit content json with html encode !

json.stringify not doing html encode

so if type in input :

enter image description here

and submits :

i see (via fiddler) sends html encode value :

enter image description here

question :

as see - i'm bit confused. common logic says db should save whatever user type 1:1.

the syntizations should made @ output

you must encode input sent server, because otherwise anti cross site scripting protection on server block entire request. however, decode input before saving db.

in other, see in post isn't saved database.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -