我们可以将javascript代码存储在mysql数据库的任意一列中吗
如果我规定将个人的 javascript 代码存储在 mysql 数据库的列中,是否会出现跨站点脚本之类的问题?
假设 twitter 有一个 mysql 数据库,并且它允许用户通过将自己的 javascript 代码上传到数据库中的选项来在自己的个人资料中显示自己的 Google Adsense 广告。它对于数据库来说是致命的吗?
Will there be any problem like cross site scripting if I make a provision for storing an individual's javascript code in a column of a mysql database?
Suppose if twitter has a mysql database, and it allows users to display their own Google Adsense ads in their own profiles by giving them an option to upload their own javascript code into their database. Is it fatal for a database?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以,但这是一个坏主意,因为您无法控制包含哪些类型的脚本。
更好的主意是允许用户在单独的字段中插入他们的 Google AdSense 标识符,并告诉他们您将为他们插入 JS 片段。只需确保标识符仅包含此类标识符中允许的字符,不允许包含 JS 代码或 HTML 标记。
Yes, you can, but it is a bad idea, as you have no control over what kind of scripts are included.
The better idea i to allow users to insert their Google AdSense identifiers within separate field and tell them you will insert JS snippet for them. Just make sure that identifier contains only chars that are allowed in such identifier, no JS code or HTML tags allowed.