关于保留字和敏感词

保留字、敏感词过滤是网站系统必不可少的2个功能。

(1)保留字:Reserved Words
也叫关键字(Keywords),编程语言预留的有特殊含义的单词,不能用于变量名、函数名等。

Java:
引用
public、class、while、continue、extends等。

const和goto是Java的两个保留字,虽然Java并没有使用它们,但也不能被用作标识符。
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html

SQL:
引用
select、from、where等。

https://www.postgresql.org/docs/current/static/sql-keywords-appendix.html
*** PostgreSQL允许使用保留字,但是需要用双引号括起来。

可以在这里查询保留字: http://www.reservedwordsearch.com/

这里要说的不是编程语言的保留字,而是在系统开发时的保留字。很多网站为了用户更容易记住个人主页提供“个性域名”功能。
  • 二级域名方式:http://rensanning.iteye.com/
  • 二级目录方式:http://www.weibo.com/rensanning
无论哪种提供方式,想象一下如果把以下2个个性域名开放给用户注册,会让其他用户以为进入了系统界面。
引用
http://www.weibo.com/help
http://help.weibo.com/


而新浪微博就是一个典型的例子,比如以下这些个性域名没有被预先保留被用户注册了,估计还有很多。
引用
http://www.weibo.com/index
http://www.weibo.com/help
http://www.weibo.com/about
http://www.weibo.com/support
http://www.weibo.com/term
http://www.weibo.com/privacy
http://www.weibo.com/contact


正确的做法,看看GitHub就知道了。
引用
https://github.com/rensanning
https://github.com/about
https://github.com/blog


Twitter的用户名保留一览:
https://dev.twitter.com/rest/reference/get/help/configuration
引用
"about", "account", "accounts", "activity", "all", "announcements", "anywhere", "api_rules", "api_terms", "apirules", "apps", "auth", "badges", "blog", "business", "buttons", "contacts", "devices", "direct_messages", "download", "downloads", "edit_announcements", "faq", "favorites", "find_sources", "find_users", "followers", "following", "friend_request", "friendrequest", "friends", "goodies", "help", "home", "i", "im_account", "inbox", "invitations", "invite", "jobs", "list", "login", "logo", "logout", "me", "mentions", "messages", "mockview", "newtwitter", "notifications", "nudge", "oauth", "phoenix_search", "positions", "privacy", "public_timeline",
"related_tweets", "replies", "retweeted_of_mine", "retweets", "retweets_by_others", "rules", "saved_searches", "search", "sent", "sessions", "settings", "share", "signup", "signin", "similar_to", "statistics", "terms", "tos", "translate", "trends", "tweetbutton", "twttr", "update_discoverability", "users", "welcome", "who_to_follow", "widgets", "zendesk_auth", "media_signup"


常见的如下:
引用
首页index/home/top、帮助help、关于about、联系方式contact、常见问题faq、技术支持support、友情链接links、文档doc、新闻news、网站地图sitemap、价格price/plan、规约term、隐私privacy、登录/退出/注册(login, logout, signup, signin, signout, account)、其他(wiki、rss、api、search)。


(2)敏感词:Sensitive Words 或 NG Words
敏感词包括政治敏感信息、暴力犯罪信息、不文明信息、不健康信息、竞品信息、电商交易信息等。但也不局限于这些,任何不合适发布的违规词都需要做屏蔽处理。对于敏感词,发布信息时会被禁止或者被自动替换为星号(*)或叉号(X)等,而搜索引擎直接不予执行搜索。比如在新浪微博搜索敏感词直接会显示:根据相关法律法规和政策,“xxxx”搜索结果未予显示。

在网上可以找到一些常见的敏感词库或过滤词库,但对于系统来说敏感词库是不固定的,会不同时时机增加或解禁。

猜你喜欢

转载自rensanning.iteye.com/blog/2359286