Welcome! » Log In » Create A New Profile

i have a problem "div style","span style"

Posted by arlong 
i have a problem "div style","span style"
October 16, 2011 07:43PM

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

Turn off magic quotes.

Re: i have a problem "div style","span style"
October 16, 2011 09:54PM

magic quotes off now but problem dont finish.

in:

text

out:

text

Re: i have a problem "div style","span style"
October 17, 2011 12:00PM
ezyang@javelin:~/Dev/htmlpurifier$ cat test.php
<?php
require_once &#039;library/HTMLPurifier.auto.php&#039;;

$config = HTMLPurifier_Config::createDefault();

$config -> set(&#039;Core.Encoding&#039;, &#039;UTF-8&#039;);

$config -> set(&#039;HTML.Doctype&#039;, &#039;XHTML 1.0 Transitional&#039;);

$config -> set(&#039;HTML.TidyLevel&#039;,&#039;medium&#039;);

$config->set(&#039;HTML.AllowedAttributes&#039;, &#039;*.style,a.href,a.title&#039;);

$config->set(&#039;HTML.AllowedElements&#039;,&#039;div,a,strong,span,em,p,u,i,b,sup,sub,small,ul,li,ol,big,code,blockquote,hr,h1,h2,h3,h4,h5&#039;);

$config->set(&#039;CSS.AllowedProperties&#039;, array(&#039;float&#039;, &#039;color&#039;,&#039;background-color&#039;, &#039;background&#039;, &#039;font-size&#039;, &#039;font-family&#039;, &#039;text-decoration&#039;, &#039;font-weight&#039;, &#039;font-style&#039;, &#039;font-size&#039;));

$config->set(&#039;AutoFormat.RemoveSpansWithoutAttributes&#039;, true);

$config->set(&#039;CSS.AllowTricky&#039;,&#039;true&#039;);

$schemes = array(&#039;http&#039; => true, &#039;https&#039; => true);

$config -> set(&#039;URI.AllowedSchemes&#039;, $schemes);

$purifier = new HTMLPurifier($config);

$dirty_html=&#039;<p><span style="color: red;">text</span></p>&#039;;
$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?

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