M
M
My Way2018-05-07 21:07:33
Laravel
My Way, 2018-05-07 21:07:33

How to display html from base in laravel?

Users can send messages to each other. And as an option, they can send a JS code that will screw everything up. But also in messages, for certain reasons, there may be html code with an image (img tag).
If you output like this {{ $message }} , then everything is safe, but the images are not displayed. And if you output like this {!! $message !}}, then the pictures appear, but they write that this is not allowed. Although the JS code is not executed.
How can I correctly display html code, the safety of which I cannot be sure of?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pavel Buchnev, 2018-05-07
@butschster

php.net/manual/en/function.strip-tags.php

D
Dmitry Kuznetsov, 2018-05-08
@dima9595

Personally, I'm also looking for solutions to this. But I made it so that bbcode would be used when creating a message, and then, where I need to display it, I converted it to html.

I
ipokos, 2018-05-08
@ipokos

can send JS code that will fuck everything up

those. you js will not execute, but still allow it to be written to the database?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question