Submitting content while in preview ignores filters

luxx - August 11, 2009 - 23:52
Project:BUEditor
Version:6.x-1.3
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hello,

BUEditor with a BBCode filter is exactly what we need for our site, and I thought it was working, however I found a pretty big problem: If you submit while in preview mode, the filter is ignored. Steps to reproduce:

1) Enter "I am [b]bold[/b]"
2) Click preview - the preview looks fine, bold is applied
3) Then click submit
4) The post will become: "I am bold"

I repeat this same process without step 2 and it works fine. So something in the preview button is causing it to revert to HTML and ignore the underlying filter (in this case BBCode).

I am using the BBCode filter provided here: http://drupal.org/project/bbcode
I am using BUEditor with the BBCode buttons provided here: http://drupal.org/node/163034

The source of the preview button is attached.

Any ideas would be greatly appreciated. Thanks.

AttachmentSize
preview_button.txt3.21 KB

#1

luxx - August 11, 2009 - 23:53

To be clear, step #4 is using the < b > bold tags which are HTML

#2

luxx - August 12, 2009 - 23:28

My first thought to fix this was to do a form alter:

When the form is submitted, do a form alter: if preview is currently turned on enabled, if it is, call function eDefPreview(NoAutoP, selOnly) in bueditor\library\default_buttons_functions.js to turn off preview, otherwise do nothing.

Only problem is knowing when it is pressed, which will require another js function, which unfortunately I have no idea how to write js.

#3

ufku - August 21, 2009 - 21:46

This is because the bbcode text is converted to html while previewing.
Adding E.setContent(E.oriCnt); after eDefPreview(); may help.

#4

luxx - August 24, 2009 - 16:47

Worked perfectly. Thanks!

#5

luxx - August 24, 2009 - 16:47
Status:active» closed
 
 

Drupal is a registered trademark of Dries Buytaert.