最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - XSS in AngularJS App - Stack Overflow

programmeradmin3浏览0评论

We are using Angular JS in our app. I want to prevent all input fields from accepting JavaScript etc. Rather than check every single ponent is there a directive or something I could use out of the box which does this for me? Thanks

We are using Angular JS in our app. I want to prevent all input fields from accepting JavaScript etc. Rather than check every single ponent is there a directive or something I could use out of the box which does this for me? Thanks

Share Improve this question asked Sep 25, 2013 at 15:00 Breako BreakoBreako Breako 6,47115 gold badges44 silver badges60 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

Rather than doing client side filtering, I would leave that to the server side ponent. But client side will need to do the input validation stuff for the sake of user friendly.

ngSanitize in angular 1.2.0 (and some earlier versions) can help you sanitize your inputs.

http://docs.angularjs/api/ngSanitize

Or, alternatively, write your own filter that runs the input through regex to strip all HTML/JS/etc.

As a note, you should still have your server sanitize the inputs as well considering users can make direct requests against your server API and you may not have client side validation there.

发布评论

评论列表(0)

  1. 暂无评论