|
i have a problem "div style","span style" October 16, 2011 07:43PM |
Registered: 1 year ago Posts: 5 |
hi <span style="COLOR:black">text</span> return <span>text</span>
<div style="font-size:12px;">text2</div> is return <div>text2</div>
my config file is:
$config = HTMLPurifier_Config::createDefault();
$config -> set('Core.Encoding', 'UTF-8');
$config -> set('HTML.Doctype', 'XHTML 1.0 Transitional');
$config -> set('HTML.TidyLevel','medium');
$config->set('HTML.AllowedAttributes', '*.style,a.href,a.title');
$config->set('HTML.AllowedElements','div,a,strong,span,em,p,u,i,b,sup,sub,small,ul,li,ol,big,code,blockquote,hr,h1,h2,h3,h4,h5');
$config->set('CSS.AllowedProperties', array('float', 'color','background-color', 'background', 'font-size', 'font-family', 'text-decoration', 'font-weight', 'font-style', 'font-size'));
$config->set('AutoFormat.RemoveSpansWithoutAttributes', true);
$config->set('CSS.AllowTricky','true');
$schemes = array('http' => true, 'https' => true);
$config -> set('URI.AllowedSchemes', $schemes);
$purifier = new HTMLPurifier($config);
$content = $purifier -> purify($dirty_html);
return $content;
i want see <span STYLE and <div STYLE HOW CAN ? DO?
|
Re: i have a problem "div style","span style" October 16, 2011 08:34PM |
Admin Registered: 6 years ago Posts: 2,632 |
|
Re: i have a problem "div style","span style" October 16, 2011 09:54PM |
Registered: 1 year ago Posts: 5 |
|
Re: i have a problem "div style","span style" October 17, 2011 12:00PM |
Admin Registered: 6 years ago Posts: 2,632 |
ezyang@javelin:~/Dev/htmlpurifier$ cat test.php
<?php
require_once 'library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$config -> set('Core.Encoding', 'UTF-8');
$config -> set('HTML.Doctype', 'XHTML 1.0 Transitional');
$config -> set('HTML.TidyLevel','medium');
$config->set('HTML.AllowedAttributes', '*.style,a.href,a.title');
$config->set('HTML.AllowedElements','div,a,strong,span,em,p,u,i,b,sup,sub,small,ul,li,ol,big,code,blockquote,hr,h1,h2,h3,h4,h5');
$config->set('CSS.AllowedProperties', array('float', 'color','background-color', 'background', 'font-size', 'font-family', 'text-decoration', 'font-weight', 'font-style', 'font-size'));
$config->set('AutoFormat.RemoveSpansWithoutAttributes', true);
$config->set('CSS.AllowTricky','true');
$schemes = array('http' => true, 'https' => true);
$config -> set('URI.AllowedSchemes', $schemes);
$purifier = new HTMLPurifier($config);
$dirty_html='<p><span style="color: red;">text</span></p>';
$content = $purifier -> purify($dirty_html);
echo $content;
ezyang@javelin:~/Dev/htmlpurifier$ php test.php
<p><span style="color:#FF0000;">text</span></p>
What does $dirty_html look like before you put it through HTML Purifier?