phalcon / cphalcon

High performance, full-stack PHP framework delivered as a C extension.
https://phalcon.io
BSD 3-Clause "New" or "Revised" License
10.79k stars 1.96k forks source link

phalcon will auto filter html tag which string contains html tags #15255

Closed liaojiansong closed 3 years ago

liaojiansong commented 3 years ago

The code looks like this.

$model = new PostModel();
$model->titile = 'hello world';
$model->content = '<p>this is something ...</p>';
$model->save();
That's what I want. title content
hello \

this is something ...\

But ,what is actually preserved is like below,the phalcon removed my \

tag

title content
hello

this is something ...

So,what am I supposed to do?

PHP:7.4.8 Phalcon:4.1.0 Mysql:5.7.24 OS:Centos7

By the way,in win10 it is ok,only in centos will remove html tag

Jeckerson commented 3 years ago

Hello

Please show your PostModel class

liaojiansong commented 3 years ago
<?php

namespace Castle\Models;

use Phalcon\Mvc\Model;

class PostModel extends Model
{
    public $id;

    public $title;
    public $content;

    public function initialize()
    {
        $this->setSource("post");
        $this->useDynamicUpdate(true);
    }

}
liaojiansong commented 3 years ago

Here is database config

    $di->setShared('db', function () use ($config,$di) {
        $dbConfig = $config->database;
        $connection = new \Phalcon\Db\Adapter\Pdo\Mysql([
            'host'     => $dbConfig->host,
            'username' => $dbConfig->username,
            'password' => $dbConfig->password,
            'dbname'   => $dbConfig->dbname,
            'charset'  => $dbConfig->charset,
            'port'     => $dbConfig->port,
        ]);

        return $connection;
    });
liaojiansong commented 3 years ago

Thank you,Jeckerson. Maybe i used the 'string' filter in the getPost() method,so my html tag was filtered out. Now,I close this issue