清理 Unicode 输入的最佳实践
我目前正在开发一个 Web 应用程序(使用 Ruby),我最终希望世界上任何地方的人们都可以使用它。考虑到这一点,对非 ASCII 字符的支持至关重要。但是,我不希望数据库在用户名等字段中充满“噪音”字符。
是否有任何公认的最佳实践可以在这些情况下处理 Unicode 输入而不疏远用户?关于处理用户名中的同形异义词以使冒充变得更加困难有什么想法吗?
到目前为止我的一些想法 -
- 在存储或在查询中使用文本之前规范化文本
- 过滤不可打印的字符
- 限制输入中允许的顺序组合变音符号的数量
还有任何进一步的想法,或者我是否为自己做了不必要的工作?
谢谢。
I'm working on a web application at the moment (using Ruby) that I would ultimately like to be usable by people from anywhere in the world. With that in mind, support for non-ASCII characters is essential. However, I don't want the database to be full of "noise" characters in fields such as username etc.
Are there any accepted best practices for dealing with Unicode input under these circumstances without alienating users? Any thoughts on dealing with homographs in usernames to make impersonation harder?
Some of my thoughts so far -
- normalizing text before storing or using it in queries
- filtering non-printable characters
- limiting the number of sequential combining diacritics allowed in input
Any further thoughts, or am I making unnecessary work for myself?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://www.ietf.org/rfc/rfc3454.txt 会告诉你什么你应该这样做,也就是说担心正常化和安全问题。
http://www.ietf.org/rfc/rfc3454.txt will tell you what you should be doing, which is to say worrying about normalization and security issues.