|
Chris Altman
Stop stripping tags that are outside of the body..June 16, 2010 01:00PM |
We are trying to figure out how to make sure html, head, meta, style, title, aren't stripped.
In an effort to stop them from being removed by HTMLPurifier we used the addElement method. We seem to be able to get them all to work EXCEPT HEAD.
$oDef = $oConfig->getHTMLDefinition(true);
$oDef->addElement(
'style', // name
false, // content set
'Optional: #PCDATA', // allowed children
'Common', // attribute collection
array( // attributes
'type' => 'CDATA',
));
$oDef->addElement(
'title', // name
false, // content set
'Optional: #PCDATA', // allowed children
'I18N', // attribute collection
array( // attributes
));
$oDef->addElement(
'meta', // name
false, // content set
'Empty', // allowed children
'I18N', // attribute collection
array( // attributes
'http-equiv' => 'CDATA',
'name' => 'CDATA',
'content' => 'CDATA',
'scheme' => 'CDATA',
));
$oDef->addElement(
'head', // name
false, // content set
'Optional: Flow | #PCDATA | title | style | meta', // allowed children
'Common', // attribute collection
array( // attributes
));
$oDef->addElement(
'body', // name
false, // content set
'Optional: Flow | #PCDATA | Inline', // allowed children
'Common', // attribute collection
array( // attributes
));
$html = $oDef->addElement(
'html', // name
false, // content set
'Optional: Flow | #PCDATA | head | body | title | style | meta', // allowed children
'Common', // attribute collection
array( // attributes
# 'action*' => 'URI',
# 'method' => 'Enum#get|post',
# 'name' => 'ID'
));
$html->excludes = array('html'=>true);
You may ask why we have title, style, meta inside the html. It's because the HEAD isn't working yet. So in the meantime we put them there since they seem to render even though they are children of HEAD.
|
Re: Stop stripping tags that are outside of the body.. June 18, 2010 08:52AM |
Admin Registered: 6 years ago Posts: 2,640 |