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 '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?

Author:
Your Email:

Subject:

HTML input is enabled. Make sure you escape all HTML and angled brackets with &lt; and &gt;.

Auto-paragraphing is enabled. Double newlines will be converted to paragraphs; for single newlines, use the pre tag.

Allowed tags: a, abbr, acronym, b, blockquote, caption, cite, code, dd, del, dfn, div, dl, dt, em, i, ins, kbd, li, ol, p, pre, s, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var.

For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and pre to preserve newlines:

<pre><![CDATA[
Place code here
]]></pre>

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}

Message: