开发者

How to prevent extremely annoying codes in user input [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago.

Is it possible to prevent characters that break the layout? Like this:

̤͎͍͖̳̙͚̭͕̠̤͎͍͖̳̙͚̭͕̠S̳͇͉̩̳ S̳͇͉̩̳ ̤͎͍͖̳̙͚̭͕̠S̳͇͉̩̳̤͎͍͖̳̙͚̭͕̠S̳͇͉̩̳

̤͎͍͖̳̙͚̭͕̠̤͎͍͖̳̙͚̭͕̠S̳͇͉̩̳̤͎͍͖̳̙͚̭͕̠S̳͇͉̩̳̤͎͍͖̳̙͚̭͕ ̠S̳͇͉̩̳

S̳͇͉̩̳̤͎͍͖̳̙͚̭͕̠S̳͇开发者_如何学C͉̩̳


You can prevent it by whitelisting UTF8 chars from a limited range, for example only the latin code points, see http://www.utf8-chartable.de/ for the hex values.


before accepting user input, check for ASCII chars then remove non-ASCII chars with this PHP code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜