doumu4032 2017-11-10 06:55
浏览 55
已采纳

在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?

  • 写回答

1条回答 默认 最新

  • doushun4666 2017-11-10 08:36
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?