config->set('CSS', 'AllowedAttributes") March 26, 2008 06:28PM |
Registered: 11 years ago Posts: 5 |
Is there an API method to define which CSS attributes are allowed? All I see is CSS.Proprietary, but I'd like to allow a restricted set of style attributes for styled text.
Here's how I'm doing it right now:
$config->set('HTML', 'DefinitionID', $name); $config->set('HTML', 'DefinitionRev', $rev); $config->set('CSS', 'DefinitionRev', $rev); $config->set('HTML', 'AllowedElements', implode(',', $els)); $config->set('HTML', 'AllowedAttributes', implode(',', $attrs)); if (!in_array('a', $attrs)) { $config->set('AutoFormat', 'Linkify', false); } $css =& $config->getCSSDefinition(); // warning: $config->isFinalized() == true $css->info = array_intersect_key($css->info, array_flip($styleattrs));
This smells like worst practices, but I don't see any other way to do it.
Thanks for all of your work. Not only is your library remarkably robust, but the code is a pleasure to work with.
Re: config->set('CSS', 'AllowedAttributes") March 27, 2008 09:00AM |
Admin Registered: 12 years ago Posts: 3,123 |
There isn't, so your method is preferred. One of these days I really need to add a %CSS.Allowed configuration parameter or something :-)
Re: config->set('CSS', 'AllowedAttributes") March 27, 2008 11:52AM |
Registered: 11 years ago Posts: 5 |
Re: config->set('CSS', 'AllowedAttributes") March 28, 2008 06:09AM |
Admin Registered: 12 years ago Posts: 3,123 |
It would be absolutely fantastic if you made a patch, but there would also need to be associated unit tests for it (also, the code would look more like that for %HTML.AllowedElements)
Re: config->set('CSS', 'AllowedAttributes") March 28, 2008 11:03AM |
Registered: 11 years ago Posts: 5 |
Re: config->set('CSS', 'AllowedAttributes") March 28, 2008 06:55PM |
Registered: 11 years ago Posts: 5 |
I e-mailed a patch to you. With a bit of work, I was able to get it set up with SimpleTest on my machine, regenerate the config schema cache, and pass a test of the new functionality, but quite a few other tests failed when I regenerated it, apparently because there are config schema files missing.
Re: config->set('CSS', 'AllowedAttributes") March 30, 2008 05:56PM |
Admin Registered: 12 years ago Posts: 3,123 |