how can I clean and sanitize a url submitted by a user for redisplay in java?

后端 未结 3 1526
孤街浪徒
孤街浪徒 2021-01-23 02:43

I want a user to be able to submit a url, and then display that url to other users as a link.

If I naively redisplay what the user submitted, I leave myself open to urls

3条回答
  •  爱一瞬间的悲伤
    2021-01-23 03:30

    I think what you are looking for is output encoding. Have a look at OWASP ESAPI which is tried and tested way to perform encoding in Java.

    Also, just a suggestion, if you want to check if a user is submitting malicious URL, you can check that against Google malware database. You can use SafeBrowing API for that.

提交回复
热议问题