From 00dc88fbf68321cfb6d6cb75796e2bdffcad7b33 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Tue, 24 Nov 2009 08:21:03 +0000 Subject: [PATCH] refine purify definition to allow for anchor tags --- phpgwapi/inc/class.html.inc.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 76eccd10e7..f953277386 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -1267,9 +1267,36 @@ class html { $config = HTMLPurifier_Config::createDefault(); $config->set('Core', 'Encoding', self::$charset); + // maybe the two following lines are useful for caching??? + $config->set('HTML','DefinitionID', 'egroupware'); + $config->set('HTML','DefinitionRev', 1); + // doctype and tidylevel + $config->set('HTML','Doctype', 'XHTML 1.0 Transitional'); + $config->set('HTML','TidyLevel', 'light'); + // EnableID is needed for anchor tags + $config->set('Attr','EnableID',true); + // actual allowed tags and attributes + $config->set('HTML', 'Allowed', 'br,p[align],b,i,u,s,em,pre,tt,strong,strike,center,div[align],hr[class|style],'. + 'ul[type],ol[type|start],li,'. + 'h1,h2,h3,'. + 'span[class|style],'. + 'table[class|border|cellpadding|cellspacing|width|style|align|bgcolor|align],'. + 'tbody,thead,tfoot,colgroup,'. + 'col[width|span],'. + 'blockquote[class|cite|dir],'. + 'tr[class|style|align|bgcolor|align|valign],'. + 'td[class|colspan|rowspan|width|style|align|bgcolor|align|valign|nowrap],'. + 'th[class|colspan|rowspan|width|style|align|bgcolor|align|valign|nowrap],'. + 'a[href|target|name|title],img[src|alt|title]'); $config->set('Cache', 'SerializerPath', $GLOBALS['egw_info']['server']['temp_dir']); } $purifier = new HTMLPurifier($config); + // the latter may enable you to modify the config later on, but by now + // the effort for e.g. enabling anchor tags is already included above + //$def =& $purifier->config->getHTMLDefinition(true); + //$def->addAttribute('a', 'name', 'Text'); + + } return $purifier->purify( $html ); }