Welcome! » Log In » Create A New Profile

Allow usemap attribute

Posted by grh 
Allow usemap attribute
June 01, 2008 05:24AM

Allowing the "usemap" attribute seems simple enough, according to the docs, but it isn't working for me. (ver 2.1.3)

    $hp_config = HTMLPurifier_Config::createDefault();
    $hp_config->set('HTML', 'DefinitionID', 'project-admin');
    $hp_config->set('HTML', 'DefinitionRev', 1);
    $hp_config->set('Core', 'Encoding', 'ISO-8859-1');
    $hp_config->set('HTML', 'Doctype', 'XHTML 1.0 Transitional');
    $hp_config->set('HTML', 'Trusted', TRUE);
    $hp_config->set('URI', 'Disable', FALSE);
    $hp_config->set('Attr', 'AllowedFrameTargets', array('_blank'));
    $hp_config->set('Core', 'DefinitionCache', null); // remove this later!
    $hp_def = $hp_config->getHTMLDefinition(true);
    $hp_def->addAttribute('a', 'target', 'Enum#_blank,_self,_top');

    $hp_def->addAttribute('img', 'usemap', 'CDATA');

Caching is disabled, and I cleared previous cache files.

What am I doing wrong?

Re: Allow usemap attribute
June 01, 2008 03:15PM

I just checked, and it works in 3.1.0. Try upgrading to 2.1.4 (which incorporates a number of bugfixes from the 3.x series)?

Also, URI would be more appropriate than CDATA in this context.

Re: Allow usemap attribute
June 01, 2008 10:46PM

Sorry to say, ver. 2.1.4 ignored the addAtribute dirrective for usemap. I see library/HTMLPurifier/AttrDef/CSS.php was modified to test CSS properties case-insensitively. Thanks for that.

I don't know if this is relevant, but I noticed a peculiar thing when I turned caching back on. Three .ser cache files were written on the first invocation, but only one of them shows a '3' corresponding to the value of 'DefinitionRev' set in my config.

[root@lindev2 DefinitionCache]# find Serializer -type f -exec ls -l {} \;
     276 Jun  1 21:25 Serializer/URI/2.1.4-acb1...f142-1.ser
  121487 Jun  1 21:25 Serializer/HTML/2.1.4-9566...be3d-3.ser
   16512 Jun  1 21:25 Serializer/CSS/2.1.4-40cd...840a-1.ser
Re: Allow usemap attribute
June 10, 2008 09:02PM

I'm currently in the process of synchronizing the PHP 4 branch, and will soon see what the issue with addAttribute is. I'm sorry it took so long to get around to this.

As for the Definition caching, that's expected behavior. DefinitionRev only applies to one namespace: HTML in your case. The other namespaces are unaffected.

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