phpxsshtmlpurifier

Modifying htmlpurifier allowed tags for this markup


My html purifier settings now allow only these tags

$configuration->set('HTML.Allowed', 'p,ul,ol,li');

I want to allow indentation of lists and my editor uses this html

<ul style="margin-left: 40px;">

How should I change my HTMLPurifier Allowed tags? I thought to add style, but I think it would be better to specify exactly which style is allowed, which in this case would be margin-left. What is the right way to change the HTML.Allowed for this case?


Solution

  • Allow the style attributes, and then modify the allowed CSS attributes using %CSS.AllowedProperties.

    $configuration->set('HTML.Allowed', 'p,ul[style],ol,li');
    $configuration->set('CSS.AllowedProperties', 'margin-left');