Welcome! » Log In » Create A New Profile

config->set('CSS', 'AllowedAttributes")

Posted by bluej100 
config->set('CSS', 'AllowedAttributes")
March 26, 2008 06:28PM

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

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

Okay. Thank you for the quick reply.

Would you like me to try to make a patch? I could reuse most of HTML.AllowedAttributes, couldn't I?

Re: config->set('CSS', 'AllowedAttributes")
March 28, 2008 06:09AM

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

I have a patch prepared, but I can't get tests/index.php to run, even after putting SimpleTest in the tests directory; it's not finding the TestSuite object. Do you require PHPUnit to be installed?

Re: config->set('CSS', 'AllowedAttributes")
March 28, 2008 06:55PM

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

I followed up with an email.

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