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 <
the html encoding should only made when outputting.
but:
having said , see stackoverflow not following rule.
when save question here @ , contains plain <
show (obviously) <
in preview pane. when submit question : submit content json with html encode !
json.stringify not doing html encode
so if type in input :
and submits :
i see (via fiddler) sends html encode value :
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
Post a Comment