How safe is client-side HTML Sanitization?

前端 未结 4 915
别那么骄傲
别那么骄傲 2021-01-02 05:52

I have been looking at Pagedown.js lately for the allure of using mark-down on my pages instead of ugly readonly textareas.

I am extremely cautious though as it seem

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-02 06:24

    Not at all safe.

    Client side sanitation/validation should be used for few reasons:

    • easier and faster way to tell the non-malicious user what he did wrong
    • decrease the number of times non-malicious user communicate with your server (in case of errors)

    Everything that you validate can be changed because the client is not controlled by you. Things like dev console, fiddler, wireshark allows you to manipulate the data in basically any way you want.

    So only server is responsible for real sanitation/validation.

提交回复
热议问题