将 fckeditor 图像限制为仅来自我的域的图像
我有一个会员网站,我们使用精彩的 fckeditor 的非常锁定版本来发布会员内容。最近,我们开始允许使用表情符号,这让会员感到高兴,但也引入了一个潜在的漏洞,因为现在可以插入来自其他域的图像以及我们提供的表情符号。
发布的所有内容都会经过预览阶段,在此期间对发布的内容进行清理,所以我想我需要一些额外的 php 来删除任何 src 表明它不是来自我们域的 img 标签(假设它是“xyz.com”) ”)。正如 drf 在第一条评论中指出的那样,这并不像最初看起来那么简单。
我确信这也适用于其他人,但我没有找到解决方案和解决方案。正则表达式不是我的强项。一如既往,任何和所有的帮助&如有建议,我们将不胜感激。
I have a members website where we use a very locked-down version of the wonderful fckeditor for posting of member content. Recently we've started allowing smileys, which makes the members happy but has introduced a potential vulnerability in that it's now possible to insert images from other domains, as well as the smileys which are served from ours.
Everything posted goes through a preview stage, during which the posted content is sanitized, so I'm thinking I need some extra php which removes any img tag whose src indicates it doesn't come from our domain (let's say it's "xyz.com"). As pointed out by drf in the first comment, this is not as straightforward as it may initially seem.
I'm sure this would apply to others too, but I haven't had any luck finding a solution & regex is not my strong point. As always, any and all help & suggestions would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有些人会告诉您 RegExp 不适合解析 HTML/XHTML。我就是其中之一。尝试使用 XML 解析器:
示例输入:
示例输出:
Some people will tell you that RegExp is not the right thing for parsing HTML/XHTML. I am one of them. Try using an XML parser instead:
Sample input:
Sample output: