Purifier icon indicating copy to clipboard operation
Purifier copied to clipboard

How to save styles?

Open Div-Man opened this issue 5 years ago • 1 comments

I want the database to remain in this form

<b>User, </b><div style="display: inline-block;"> Hello</div>

But after processing

$textComment = Purifier::clean($request->text, 'titles');

The style attribute is deleted.

<b>User, </b><div> Hello</div>

Div-Man avatar Jul 16 '19 17:07 Div-Man

you can change its default configuration, its already mentioned here , you can do it

Edit: you can change which attributes you would like to modify so , if you want to have style attribute in your div tag , you can do it like div[style] in 'HTML.Allowed , if you also want to allow any other attribute like data-attribute you can do it as OR( | ) operator. div[style|data-attribute]

'default' => [
            'HTML.Doctype'             => 'HTML 4.01 Transitional',
            'HTML.Allowed'             => 'div[style],b,strong,i,em,u,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src]',
            'CSS.AllowedProperties'    => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align',
            'AutoFormat.AutoParagraph' => true,
            'AutoFormat.RemoveEmpty'   => true,
        ],

bikify avatar Aug 08 '19 07:08 bikify