Forums | Mahara Community

Developers /
Fix for "phantom bullet" in TinyMCE - a good one?


Don Presant's profile picture
Posts: 255

05 October 2011, 17:35

I'm posting this issue/solution here to see if my provider's solution is a good one...at his request. If the solution is validated, we'll apply it to the production server. If not, I'm open for alternatives.

I recently noticed in v1.4 with nested unordered lists, where the indented bullet has two bullets on the line, as here, on the production server:
https://careerportfolio.mb.ca/view/view.php?id=904

This only shows up on the rendered page...preview looks fine.

Here is the analysis and solution from my freelance developer...his solution works - see here on the test server:
http://careerportfolio.mb.ca/sbmahara/view/view.php?id=1207

But I think this would be called a hack, and therefore harder to maintain...thoughts from anyone?

And why did this show up only recently? I haven't had this issue in applications like pbwiki which also uses TinyMCE.

****************************
The problem here is being caused directly by htmlpurifier. On rendering, the purifier is wrapping sub lists (ul, ol) with list tags (li). It does this because its job is to remove malicious code and to generate XTHML compliant code.**

This is very unfortunate, because while it may now be nicely compliant with standards, we get the rogue list item and its bullet.

As far as I can see (I may be wrong), there is no way to style this bullet off the page using CSS. This is because we aren't able to access the content to apply a class or ID to the sub items.

A Solution

The only solution I can see involves a patch to the core htmlpurifier code:

- adding a new option to the HTML Purifier to choose between valid and invalid list nesting
- applying this new option in /lib/web.php to turn on invalid list nesting

I have written this patch and tested it on the staging site - it seems to work.

The change requires:
1. A patch to the list module for html purifier 
2. The addition of a htmlpurifier option file
3. Generation of a new cache for htmlpurifier
4. Addition of a new option to lib/web.php
...so four files to maintain.
A more crude way of doing it would be to just patch the html purifier file (step 1) which would mean only one file to maintain.

I think it would be a good idea to approach the core team with this solution and get some feedback.

anonymous profile picture
Account deleted
Posts: 112

05 October 2011, 19:56

Have you tried to replace your tinymce with the current version?  I think that we should rule out a bug that might already be fixed in TinyMCE's current version.

There is a configuration settings "fix_list_elements".  That configuration is turned off by default.  Have you tried to turn it on to see if that fixes your problem?

Melissa

Don Presant's profile picture
Posts: 255

06 October 2011, 7:44

I don't think it's an issue with tinymce - that layout renders fine in the editor. The problem only comes on rendering to the page via the 'clean_html' function which invokes the purifier.

anonymous profile picture
Account deleted
Posts: 112

06 October 2011, 9:49

Just tested it.

Adding the following line to the web.php file fixes the problem (tested in TinyMCE 3.4.6):

    fix_list_elements : true,

The bugs I added that are related to TinyMCE I added the tag TinyMCE, so they can be all added at once.

Melissa

Don Presant's profile picture
Posts: 255

06 October 2011, 11:46

Thanks Melissa, very helpful! A slick solution that we will apply.

If this can make it into core, that will be easier to maintain.

Kristina Hoeppner's profile picture
Posts: 4729

07 October 2011, 3:44

Hello Don,

One way to speed up things making it into core Mahara that are in review is to test them (as you've already done Smile) and to give your approval in the Mahara review system. Only a select number of experienced Mahara developers can perform a code review, but you can still give your stamp of "verified" approval. No specific technical knowledge is needed for that except for knowing how to get the code into your testing environment. As you encountered the problem first-hand, you will know how to reproduce it best.

Cheers

Kristina

François Marier's profile picture
Posts: 411

09 October 2011, 18:17

Small correction: everybody is able to give a code review of -1 or +1 (-2 and +2 being reserved for members of the Mahara Reviewers team) but the Verified option is restricted to people who are members of the Gerrit testing group.

Cheers,

Francois

François Marier's profile picture
Posts: 411

06 October 2011, 21:41

Thanks for the solution Melissa. I have created a patch for it:

  https://reviews.mahara.org/#change,781

Cheers,

Francois

8 results