Welcome! » Log In » Create A New Profile

style tag

Posted by atDev 
style tag
August 16, 2010 12:00AM

When attempting to allow the "style" attribute we get an error.

Is there documentation on this or why it is not allowed? (not the tag, the attribute)

Re: style tag
August 16, 2010 12:18AM

What is the error you're getting? If you see 5C in the output, turn off magic quotes. What is your configuration?

Re: style tag
August 16, 2010 10:56AM

We get: [08-16-2010 02:28:34am] Global attribute 'style' is not supported in any elements

Does this mean we have not set an allowed element which supports the style tag?

Re: style tag
August 16, 2010 12:42PM

But that's wrong, because all elements should all style tags, unless you've allowed no elements at all. What's your config?

Re: style tag
August 30, 2010 11:15PM

We use this:

$config = HTMLPurifier_Config::createDefault();
        $config->set('HTML', 'Doctype', 'HTML 4.01 Transitional');
        $config->set('Cache', 'DefinitionImpl', null);
        $config->set('HTML', 'TidyLevel', 'none');
        $config->set('HTML', 'AllowedElements', array('span'));
        $config->set('HTML', 'AllowedAttributes', array('style'));  
        $config->set('Filter', 'YouTube', true);
        $this->filter = new HTMLPurifier($config);
Re: style tag
August 31, 2010 08:58AM

Ah, there you go. You need to write *.style, not just style.

jwaldek
Re: style tag
November 09, 2010 09:16AM

$config->set('HTML', 'AllowedAttributes','*.style');

overwrite all defined attributes.

is there any way to to add new attribute but not overwrite existing set of attributes?

Re: style tag
November 09, 2010 09:30AM

Well, if you want all the defaults, then don't specify allowed elements or attributes...

jwaldek
Re: style tag
November 15, 2010 07:35AM

i want all default + "style" atribute for all elements

i try this: $def->addAttribute('*', 'style', 'CDATA');

but it not works and i must add long list :

$def->addAttribute('span', 'style', 'CDATA'); $def->addAttribute('table', 'style', 'CDATA'); $def->addAttribute('tr', 'style', 'CDATA'); $def->addAttribute('td', 'style', 'CDATA'); $def->addAttribute('th', 'style', 'CDATA'); $def->addAttribute('img', 'style', 'CDATA'); $def->addAttribute('div', 'style', 'CDATA'); $def->addAttribute('iframe', 'style', 'CDATA'); $def->addAttribute('p', 'style', 'CDATA'); $def->addAttribute('font', 'style', 'CDATA'); $def->addAttribute('ul', 'style', 'CDATA'); $def->addAttribute('li', 'style', 'CDATA'); $def->addAttribute('ol', 'style', 'CDATA'); $def->addAttribute('i', 'style', 'CDATA'); $def->addAttribute('u', 'style', 'CDATA'); $def->addAttribute('a', 'style', 'CDATA');

....

Re: style tag
November 15, 2010 09:20AM

Whoa whoa slow down for a moment. You've waded way off into the bushes: you most certainly don't want to be using addAttribute. Try *.style inside %HTML.AllowedAttributes or *[style] inside %HTML.Allowed

jwaldek
Re: style tag
November 16, 2010 11:15AM

$config->set('HTML.AllowedAttributes','*.style');

lost all default directives and i've got error message:

Required attribute 'src' in element 'img' was not allowed, which means 'img' will not be allowed either Required attribute 'action' in element 'form' was not allowed, which means 'form' will not be allowed either

$config->set('HTML.Allowed','*.[style]');

i've got error mesage:

Global attribute '*' is not supported in any elements (for information on implementing this, see the support forums)

Re: style tag
November 16, 2010 11:23AM

So... what set of elements/attributes do you want? I assumed that you already had an Allowed/etc preamble. If you want everything that is safe, just don't set anything and it will Just Work(TM).

Sorry, you do not have permission to post/reply in this forum.