Welcome! » Log In » Create A New Profile

Lots of Necessary Code Being Removed

Posted by Crestien 
Lots of Necessary Code Being Removed
January 10, 2008 10:33AM

I have a CMS that uses FCKEditor and below is some of the resulting HTML a client of mine has created. Make fun of it all you want, this is the what the system created and it "Works" when they submit it. However, when I run it through the default htmlpurifier it removes all of the images and white space. White space I understand, but the images seems to be a bit much.

I tried it on the demo version on this site as well and kept getting the same results.

I also can't post my code on here since this durn thing keeps telling me it thinks I'm spamming it. I'm trying to trim it down some, but that may reduce the relevancy or help it could provide in finding a solutions.

Re: Lots of Necessary Code Being Removed
January 10, 2008 10:35AM
Re: Lots of Necessary Code Being Removed
January 10, 2008 11:01AM

I meant to post this in support dang it. Sorry about that.

Re: Lots of Necessary Code Being Removed
January 10, 2008 01:21PM

This is, indeed, a bug in HTML Purifier. The minimal test case is:

<span><span><h3>23</h3>

HTML Purifier doesn't appear to be auto-closing multiple tags properly, so FCKEditor's very poorly formed output is making HTML Purifier think that everything afterwards is in a span tag. If you try demo'ing h3 and below, you'll find the images render properly.

I'll fix this in HTML Purifier. In the meantime, see if FCKEditor has an option to produced "well-formed" HTML (or maybe even XHTML).

Re: Lots of Necessary Code Being Removed
January 10, 2008 02:40PM

http://wiki.fckeditor.net/Developer%27s_Guide/Configuration/Configurations_Settings#DocType

Per the FCKEditor docs I have enabled the doc type correctly to XHTML Transitional now. Maybe that will help.

You may experience more of these requests because it seems that on the most recent upgrade of FCKEditor, he now spits out lots of span tags instead of combining styles on one span tag so iIf I bold and increase the font size on something I get:

<span style="font-size:16px;"><span style="font-weight:bold;">big and bold</span></span>

Thanks and I appreciate your work on this project!

Re: Lots of Necessary Code Being Removed
January 10, 2008 04:38PM

Here's a patch to fix the code if you can't fix FckEditor. The fix will be included with 3.0.1.

Index: HTMLPurifier/Strategy/MakeWellFormed.php
===================================================================
--- HTMLPurifier/Strategy/MakeWellFormed.php	(revision 1491)
+++ HTMLPurifier/Strategy/MakeWellFormed.php	(working copy)
@@ -156,10 +156,9 @@
                     // the parent
                     if (!isset($parent_info->child->elements[$token->name])) {
                         if ($e) $e->send(E_NOTICE, &#039;Strategy_MakeWellFormed: Tag auto closed&#039;, $parent);
-                        // close the parent, then append the token
+                        // close the parent, then re-loop to reprocess token
                         $result[] = new HTMLPurifier_Token_End($parent->name);
-                        $result[] = $token;
-                        $this->currentNesting[] = $token;
+                        $this->inputIndex--;
                         continue;
                     }
                     
Re: Lots of Necessary Code Being Removed
January 10, 2008 05:05PM

That worked like a charm. This is officially my favorite Open Source Project.

Thanks again,

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