Preventing HTML and Script injections in Javascript

后端 未结 7 1815
粉色の甜心
粉色の甜心 2020-12-04 13:12

Assume I have a page with an input box. The user types something into the input box and hits a button. The button triggers a function that picks up the value typed into the

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 13:29

    A one-liner:

    var encodedMsg = $('
    ').text(message).html();

    See it work:

    https://jsfiddle.net/TimothyKanski/wnt8o12j/

提交回复
热议问题