Answer the question
In order to leave comments, you need to log in
How to display a post in Laravel view without XSS, but with other tags?
Greetings to all,
I am writing a project on Laravel and I can’t find an answer anywhere,
how can I display the text of the article from the database in the blade so that only the white list of html tags goes through,
but, let’s say the script tag is not executed.
I searched, but found only these options: Markdown and purifier
Is there really nothing better? For some reason, I can't believe it... So many blogs are made on laravel, how are tags filtered then?
Share your experience, experienced)
Answer the question
In order to leave comments, you need to log in
If you definitely need html, then HTMLPurifier will help. I don’t know why you didn’t like it, it does exactly what you need: it filters tags.
It is possible to filter content through strip_tags with a list of allowed tags (but this is not 100% guaranteed).
In general, XSS is a rather complicated topic, and it is better to try to avoid using pure HTML anywhere ... It is
better to use editors with support for BB code or the same Markdown.
Of course it's too late, but for those who find it through the search engine https://github.com/MasterRO94/laravel-xss-filter
you need to do this way
{!! $text !!}
string will auto escape when you perform {{ }}
stackoverflow.com/questions/29253979/laravel-5-dis...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question