Skip to content

I need help, they say v-html is not safe, but how would I render posts from database? #6386

Discussion options

You must be logged in to vote

v-html is as safe as the HTML that you consume. Ideally, you should sanitize the HTML in you back-end, before saving the content in the database.

If you (or your team) don't control the the database, you should sanitize the content on the front-end. Apart from the great suggestions by @liulinboyi, I've created a Vue wrapper to the great sanitize-html library:
https://github.com/leopiccionia/vue-sanitize-directive

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@JenuelDev
Comment options

Comment options

You must be logged in to vote
1 reply
@JenuelDev
Comment options

Answer selected by JenuelDev
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants