1

Topic: TinyMCE not converting characters into HTML entities

I've read through lots of documentation and tried various settings, however I cannot get TinyMCE to convert characters into their respective HTML entities.  I'm pulling my hair out here.

Ok, I've tried this to be as simple as can be:

tinyMCE.init({
            theme : "advanced",
            mode : "exact",
            elements : "TEST"
        });


<textarea id="TEST" name="TEST"  cols="60" rows="20" wrap=""></textarea>

So although I'm specifying neither entity_encoding nor entities, the defaults (as can be seen in the TinyMCE source) are named and a long list of entity number-name pairs that covers everything I need converted and more respectively.

If I paste in say, a right single quote (’), Even if I select a character from the charmap, it is inserted raw. I can tell this by viewing the source, and when it is submitted and in turn saved to the database.

I've tried explicitly setting the configuration like so...

tinyMCE.init({
            theme : "advanced",
            mode : "exact",
            elements : "TEST",
            entity_encoding : "numeric",
            entities : "8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo"
        });

But still no characters are converted, so here are my questions.

1. Am I missing an extra config setting? (e.g. convert_these_symbols_on_the_double : true)
2. When exactly should these entity conversions be taking place? (e.g. as soon as I insert the character?)

My user base likes to paste things in from Word which include those annoying "smart" quotes. Since I won't be able to change their behavior I'd at least like to change the editor's.

As always, any help on this would be greatly appreciated.

Thanks,
Steve

2

Re: TinyMCE not converting characters into HTML entities

entity_encoding : "numeric", says it to convert all entities to numeric ones like * not & so switch that to entity_encoding : "named", or remove it since that is the default value. Also check so that your server side doesn't entity decode it some where.

Best regards,
Spocke - Main developer of TinyMCE

3

Re: TinyMCE not converting characters into HTML entities

Hello,

I have exactly the same problem as the OP. Quotes which are inserted in TinyMCE 3.1.0.1 are not being converted in the corresponding html entity ".

Please have a look to your own example editor on http://tinymce.moxiecode.com/example_fu … ample=true :

When I insert a "hallo" and save the page, the output is:

HTML output from post
HTML output: "hello"

Source output from post
Source output: <p>"hello"</p>

As you can see, it should be: <p>"hello"</p>

Why are the quotes not being converted to html entities?
Thank you for your help!

Best regards,

Thorsten

4

Re: TinyMCE not converting characters into HTML entities

I didn't find any solution, so sorry to post in a thread that is almost a year old.

Is there any solution for this problem?

With the latest release i have the same problem...

5

Re: TinyMCE not converting characters into HTML entities

Quotes (and we speak of double quotes) only need to be encoded into entities when they are used in attribute values. As simple innerHTML double quotes are OK.

So what's your problem?

Greetings from Germany,

Felix Riesterer.
(-> about me and this forum <-)

6

Re: TinyMCE not converting characters into HTML entities

The problem is fixed when i was adding addslashes before inserting into my database?

Why this was changed? In previous versions of tinymce they where encoding also innerHTML quotes...

7

Re: TinyMCE not converting characters into HTML entities

Yes, but that's not needed the output of TinyMCE is 100% XML compatible.

Also if you have issues inserting things with " into the database I suggest reading up on SQL injections and mysql_escape_string.

Best regards,
Spocke - Main developer of TinyMCE

8

Re: TinyMCE not converting characters into HTML entities

It would be nice to offer an option to be able to encode or not to encode quotes.

Despite of the fact that the unencoded output is xml compatible it could be necessary for developers to encode quotes for other reasons (e.g. database or web application issues) which do not lie in their own responsibilty. 

Would this be possible, or would this be too expensive?

Best regards,

Thorsten

9

Re: TinyMCE not converting characters into HTML entities

thor wrote:

It would be nice to offer an option

It would be nice if you took TinyMCE for what it is and if you dealt with the submitted code in your backend accordingly.

thor wrote:

it could be necessary for developers to encode quotes for other reasons (e.g. database or web application issues) which do not lie in their own responsibilty.

Sorry, but this is bullshit! It isn't "could be necessary", man! It is an absolute MUST!!! You must encode data according to the context at hand. This is indeed your responsibility as a developer! Anything else is downright dangerous!

If you don't believe me then do as spocke suggested and search for information on "SQL injection" and other security-related topics.

Greetings from Germany,

Felix Riesterer.
(-> about me and this forum <-)

10

Re: TinyMCE not converting characters into HTML entities

Nope, don't see why I can't see one reason why it would some how fail to store contents with " characters in the database. If you really need to encode it for some unknown reason simply post process replace the " with ".

Best regards,
Spocke - Main developer of TinyMCE

11

Re: TinyMCE not converting characters into HTML entities

You're being a bit dismissive of thor's comments, there, Felix.

Leaving aside why you'd want to do it, according to the TinyMCE documentation, the entities *should* be replaced by their entity if listed in the entity list with entity_encoding set to "named", but they aren't. So presumably this is a bug?

Setting

encoding : "xml"

does seem to result in double quotes being converted into their entity equivalents, but then sends all other elements haywire: a <p> tag in the HTML source becomes >p< when it gets posted to the next screen, even without the named entity encoding.

(See also http://tinymce.moxiecode.com/punbb/view … pid=62982)