How do I bring an HTML code stored in the Mysql database and print it on screen using MVC Express Node.js Project?

Asked

Viewed 69 times

-4

I want to print this code that is stored in the database in my project. inserir a descrição da imagem aqui

And this is coming up instead of the code inserir a descrição da imagem aqui

Here is the DAO providing the database information inserir a descrição da imagem aqui

Here is the CONTROLLER that makes the request inserir a descrição da imagem aqui

And here’s the EJS which is where the user sees the topic inserir a descrição da imagem aqui

I’ve researched on the Internet but can’t find anything to help me in this problem.

this code is stored with summernote editor in Mysql I used LONGTEXT to store in mysql

1 answer

3


According to the documentation of the EJS, the tag you are using (<%=) will print text escaped.

To print text that is not escaped, you must use the tag <%-. Thus:

<%- topico.mensagem %>

Remember that this can have serious security consequences. Rest assured topico.mensagem is a safe amount before printing it on the screen. You may be opening your site to serious vulnerabilities like Cross-Site Scripting (XSS) if you are not handling the data correctly.

  • Thank you very much, I hadn’t learned that.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.