Jump to content

Security concern. Decoding the html input on product description before saving it in the database.


orion_1988

Recommended Posts

I developed a module which grabs information about the product from another cross domain site (CROX job) and save it in the description field for the specific product as HTML. 

 

When I use:

....

$product -> description = htmlentities($input);

$product -> save();

 

the  $input HTML get property escaped and stored in the database.

 

post-1358011-0-05830100-1495095994_thumb.png

 

 

When  I open the specific product in prestashop back office, load the description field, change something and then hit "Save", the value get stored as clean HTML with all the tags etc. I know that in Product.php the variable description is set  as TYPE_HTML and Validate::isCleanHTML is enabled, but I dont think that this validation is enough and seeing pure HTML code in the database is like a nightmare for me. 

 

post-1358011-0-23186400-1495096001_thumb.png

 

So I want to add second security step and escape the input from the back office description field  before storing it  again in the database, but I am unable to find the proper code and add htmlentities before prestashop stores it in database.

 

Could someone point me to the right peace of code or advise me how to do it?

 

Many thanks in advance.

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...