清理 Unicode 输入的最佳实践

发布于 2024-10-19 19:14:10 字数 359 浏览 5 评论 0原文

我目前正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愿与i 2024-10-26 19:14:10

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文