Web Hosting Talk







View Full Version : Special chars being appended to TinyMCE content in Internet Explorer?


alias3729
09-05-2009, 05:35 PM
Hello,

I'm having a bit of a problem here and have tried everything I know to get this to work.

I've got a registration page where you get to compose a small HTML block using TinyMCE.

After you submit, it takes you to a preview page. If you want to make changes, you click the "Make Changes" button, which is inside of a form where the HTML content is stored in a hidden field. Upon clicking the Make Changes button, it posts the hidden fields back to the main form page where all the data is placed back into their various form fields.

The problem is that with Internet Explorer, as you click back and forth between Preview and Make Changes, special characters are appended to the end, such as the HTML string "�". These characters are then showing up on the preview screen, and consequently, the final product.

I'm at my wit's end trying to figure this out. Any suggestions?
The link to the page in questions is http://fred.gabrielsangels.org/events_fundraiser.php?e=7

The code is being displayed on the Preview page by the following statement:

utf8_encode(stripslashes($_POST['htmlcode']))

Upon clicking "Make Changes", the code is then placed back into the form using the following statement:

str_replace("�","",stripslashes(html_entity_decode($_POST['content']))

I've tried str_replace to remove the rogue strings, htmlentities, htmlspecialchars, utf8_encode, made sure the page encoding was utf8, even switching to the new CKEditor, only to discover the same result. Now these guys are in a panic because of this issue.

To consider this solved, the page will not display those weird characters in the editor or on the preview page. Any assistance would be appreciated...thank you much.

Steve_Arm
09-06-2009, 01:15 PM
This is how you get the code from tinymce:
tinyMCE.getContent()
So you need to get this first and then validate the form.

If you want to clean utf8 html content this function will do it:


public function utf8_urldecode($str)
{
return html_entity_decode(preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;", urldecode($str)), NULL, 'UTF-8');
}