nicedit - 它安全吗?它是否受到网站 CSS 的影响?
我正在考虑在我的网站上使用 nicedit (http://nicedit.com/)。
我假设 nicedit 只是使用按钮创建简单的 html,并且当用户保存该 html 时发送该 html。
- 推荐吗?有人还在研究吗?
- 假设我稍后在我的网站某处显示此 HTML,由于用户能够植入恶意 JavaScript,这不是很危险吗?如果不是,nicedit 如何防止这种情况发生?
- 另外,当我稍后显示这个HTML时,它会受到我的CSS的影响吗?如果是这样,我该如何防止这种情况发生?
谢谢。
I'm considering using nicedit (http://nicedit.com/) for my site.
I assume that nicedit simply creates simple html using the buttons, and that html gets sent when the user saves it.
- Is it recommended? Is someone still working on it?
- Assuming I'm later displaying this HTML in my site somewhere, isn't it dangerous due to the user being able to plant malicious javascript? If not, how does nicedit prevents this?
- Also, when I display this HTML later, will it be affected by my css? If so, how can I prevent this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我所使用的,它就像一个魅力,可以在放入数据库之前清理 nicedit 实例的内容
This is what I use it works like a charm for cleaning out the content of the nicedit instance before chucking into the database
它似乎不再被维护。但我已经将它用于我只需要一个简单/轻量级所见即所得编辑器的用途。如果您正在寻找不断获得核心更新或附加功能的东西,我不会指望它。我终于崩溃了,写了很多我自己的功能,比如表格和 YouTube 视频。
是的,黑客可以使用它在您的网站上发布客户端和/或服务器漏洞。但这是任何编辑都可能面临的威胁。您需要过滤两种方法的代码。
您需要通过清理 post 变量来防止 SQL 注入。我总是把它放在脚本的开头来清理它们,并使用
$input['whateveryouarepassing']
而不是$_POST['whateveryouarepassing']
调用它们。编辑$mysqli->real_escape_string()
部分以使用您的数据库对象。使用 MySQLi 或 PDO 以及准备好的语句来帮助强化攻击。然后我喜欢用这个函数来清理它,多年来我用各种方法来清理坏代码。如果可以设置,请改用 HTML Purifier。如果没有的话,这就是这个坏男孩。使用
cleanHTML($input['whateveryouarepassing']);
调用它。HTML在编辑和显示时会受到CSS的影响。如果这是一个问题,您将需要编写额外的 CSS 规则。如果问题是在编辑时移动到基于 iframe 的编辑器,并防止 css 在 iframe 中显示 html 内容。
如果您需要其他建议,elRTE 是我这些天的首选编辑。更高级一点,但一旦您了解了代码库和 API,就完全值得了。您将像任何编辑一样面临与上述相同的问题。编辑期间的 CSS 除外,因为 elRTE 是基于框架的,您可以指定样式表。 elRTE 主页
编辑:我发布此内容假设您使用的是 PHP。如果没有,抱歉。
It doesn't appear to be maintained anymore. But I have used it for purposes where I needed just a simple/lightweight WYSIWYG editor. If you are looking for something that gets constant core updates or additional features I wouldn't count on it. I finally broke down and wrote a lot of my own features like tables and YouTube videos.
Yes, a hacker could use it to post an client and/or server exploit on your site. But this is a threat you can face with any editor. You need to filter the code for two methods.
You need to prevent SQL injection by sanitizing your post variables. I always put this at the beginning of my scripts to clean them and call them with
$input['whateveryouarepassing']
instead of$_POST['whateveryouarepassing']
. Edit the$mysqli->real_escape_string()
parts to work with your database object. Use MySQLi or PDO with prepared statements to help harden the attack.Then I like to clean it with this function I put together over the years with various methods of cleaning out bad code. Use HTML Purifier instead if you can set it up. If not, here is this bad boy. Call it with
cleanHTML($input['whateveryouarepassing']);
.The HTML will be affected by your CSS when editing and displayed. You will need code additional CSS rules if this is an issue. If the issue is when editing move to a iframe based editor and to prevent the css display the html content in an iframe.
If you want another suggestion elRTE is my goto editor these days. A little more advanced but totally worth it once you get to know the code base and API. You will face the same issues as above as will any editor. Except the CSS during editing since elRTE is framebased and you can specify stylesheets. elRTE Homepage
Edit: I posted this assuming you were using PHP. Apologies if not.