简体   繁体   English

tinyMCE发布带有脚本标签的代码?

[英]tinyMCE posting code with script tags?

I have created a page to create articles http://8mags.com/bored/people/ When I posted an article with script tags and other HTML tags it came out with scripts tag here is the link to generated article http://8mags.com/bored/people/stories/59b4f0c3a94d5f2637b376be6e554480.php Is this a security threat? 我创建了一个页面来创建文章http://8mags.com/bored/people/当我发布带有脚本标签和其他HTML标签的文章时,它带有脚本标签,这是生成的文章http:// 8mags的链接.com / bored / people / stories / 59b4f0c3a94d5f2637b376be6e554480.php这是安全威胁吗? How can I prevent it? 我该如何预防? Here is the code that I am using 这是我正在使用的代码

if (!empty($_REQUEST['content'])&&!empty($_REQUEST['title'])&&!empty($_REQUEST['writer'])) {
$title = $_POST['title'];
$content = $_POST['content'];
$writer = $_POST['writer'];
require_once 'htmlpurifier/library/HTMLPurifier.auto.php';
$purifier = new HTMLPurifier();
$pure_content = $purifier->purify($content);
$entity_content = htmlentities($pure_content);
$entity_content = $mysqli->real_escape_string($entity_content);
$slashedtitle = addslashes($_POST['title']);
$slashedcontent = addslashes($_POST['content']);
$slashedwriter = addslashes($_POST['writer']);
$mysqli->query("INSERT INTO stories (TITLE, WRITER, CONTENT, UPVOTE, DOWNVOTE) VALUES ('$slashedtitle', '$slashedwriter', '$slashedcontent', 0, 0)");

There is no security threat as far as I can see. 据我所知,没有安全威胁。 By using HTMLPurifier all malicious code should be removed. 通过使用HTMLPurifier,应该删除所有恶意代码。

What happend here I suspect is that the tinyMCE editor converted your written code into HTML entities before the form was submitted., eg <script> was converted to &lt;script&gt; 我怀疑这里发生的是,tinyMCE编辑器在提交表单之前将您的书面代码转换为HTML实体。例如, <script>被转换为&lt;script&gt; . Therefore the code doesn't get executed in the browser and can't be malicous. 因此,该代码不会在浏览器中执行,并且不会恶意。

If you want to test what happens to malicous code do it right and use a tool like Firebug to inject the code into the editor, so it can't get escaped. 如果您想测试恶意代码会发生什么,请正确执行,并使用Firebug之类的工具将代码注入编辑器,这样就无法转义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM