在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.
But when I open the same page from the cloud (an external Webserver) the HTML tags are sanitized on Chrome and Firefox.
What's the cause of this behaviour and how can I prevent the sanitized html tags?
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.