Welcome! » Log In » Create A New Profile

Problem to configure HTMLPurifier.

Posted by Pixcell 
Pixcell
Problem to configure HTMLPurifier.
August 17, 2012 04:18AM

Hello,

I'd like to know if it was possible to configure HTMLPurifier to allow HTML code like :

<tr>
<td> Blabla </td>
<td> Blop </td>
</tr>

I want to give the user the possibility to put only a table row, without

tags ....

I use HTMLPurifier for cleaning HTMLcode in forms (coming for text-aera zones)

The result after : $r = purifier->purify("

<tr>
<td> Blabla </td>
<td> Blop </td>
</tr>

")

$r = "Blabla Blop". I lost all my table row.

Thanks for your help. (and sorry for my bad english, I hope you understood me)

Re: Problem to configure HTMLPurifier.
August 17, 2012 04:10PM

Are you inserting the resulting HTML into a table? Yes we can do that, set %HTML.Parent to 'table' and rejoice.

Pixcell
Re: Problem to configure HTMLPurifier.
August 20, 2012 08:22AM

Thx, yes I insert the HTML code in a table. But HTMLPurifier doesn't know that. Your fix doesn't works because its a "global" fix and I don't know if the user is gonna give me a row of a table or not. I can't define parent to "table" cause it wont be true every time.

Re: Problem to configure HTMLPurifier.
August 21, 2012 09:49AM

...surely you know where the HTML code the user code is going to end up, right? Have two versions of your config option.

Pixcell
Re: Problem to configure HTMLPurifier.
August 22, 2012 04:01AM

Yeah ... but no ...

I can't know if its gonna be juste a row of a table, an image or whatever... That's the point. The user is giving me a part of the HTML of an e-mail.

Re: Problem to configure HTMLPurifier.
August 22, 2012 02:14PM

Then I don't understand the question. The HTML wouldn't have rendered properly in the email either, no?

Pixcell
Re: Problem to configure HTMLPurifier.
August 23, 2012 08:33AM

In fact, I assemble two parts of HTML code, to make one email. But I'll never know the contents of those parts. the problem is when, for exemple : one part is just a row of a table.

Looking forward in your documentation, I think that what I wanna do is impossible. Because I can't tell what kind of HTML code I'm going to have.

Re: Problem to configure HTMLPurifier.
August 23, 2012 02:18PM

I still don't quite understand what you are doing; it probably is the direct approach with HTML Purifier is wrong, but there might be a more major change in strategy that gets the desired end effect.

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: