在localhost上更正html标签,但在web甚至相同的PHP代码和数据库中进行了清理

在localhost上更正html标签,但在web甚至相同的PHP代码和数据库中进行了清理

问题描述:

I'm trying to figure out a strange issue I stumbled on:

Locally and on external server I use the same web environment thanks to Ansible and Vagrant.

I use Ubuntu, Apache Webserver, MySQL, PHP 7, Codeigniter 3.

On the edit form I see on localhost correct HTML tags.

localhost

But when I open the same page from the cloud (an external Webserver) the HTML tags are sanitized on Chrome and Firefox.

enter image description here

What's the cause of this behaviour and how can I prevent the sanitized html tags?

我试图找出一个我偶然发现的奇怪问题: p>

在本地和外部服务器上,由于Ansible和Vagrant,我使用相同的Web环境。 p>

我使用Ubuntu,Apache Webserver,MySQL,PHP 7,Codeigniter 3. p>

在编辑表单上,我在localhost上看到正确的HTML标记。 p>

p>

但是当 我从云(外部Web服务器)打开同一页面,在Chrome和Firefox上清理HTML标签。 p>

p>

此行为的原因是什么?如何防止已清理的html标记? p> div>

If you haven't bothered to set CI_ENV correctly in either your configuration file application/config/config.php or via apache (either in .htaccess or apache conf) then you might get different behavior on the two different machines.

You should also check application/config/config.php for this value and see what it's set to:

$config['global_xss_filtering'] = FALSE;

Obviously, if you've bothered to define different config.php values in these locations, you may need to check them also:

application/config/development/config.php
application/config/testing/config.php
application/config/production/config.php

As a sanity check, you might want to define a controller method like this and see if it outputs different values on your respective machines:

public function ci_check() {
    echo CI_ENV;
}

If you find that the machines have different CI_ENV values, it may be that each machine is loading a different configuration file for config value global_xss_filtering. This might cause the problem you are seeing. Sort of hard to say without seeing more code.