This is a migrated thread and some comments may be shown as answers.

ConvertCharactersToEntities and Scripts

4 Answers 130 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Dan Ehrmann
Top achievements
Rank 1
Dan Ehrmann asked on 17 Apr 2015, 03:25 PM

I was having trouble with the Insert Symbol tool - it would insert (for example) Ω which looks nice. But, after saving a re-opening the editor, the Ω was gone, replaced by an unknown character glyph. I enabled the ConvertCharactersToEntities filter so that the Insert Symbol tool would insert the entity code for the chosen symbol - in this example, Ω

This worked great until I tried to insert some javascript. My script included something like this:

    if (x > 5)

This got converted to:

    if (x > 5)

which doesn't work very well.

How can I keep my entities and still allow javascript?

4 Answers, 1 is accepted

Sort by
0
Dan Ehrmann
Top achievements
Rank 1
answered on 17 Apr 2015, 03:55 PM

I have partially answered my own question - I was not saving editor content as unicode in my database, so special characters were getting lost. Encoding them fixed that problem, but then caused the script problem. I am going to start moving to Unicode storage (probably should have done that a long time ago...)

 I would still like to know about the entity conversion happening in scripts. That doesn't seem like proper behavior.

0
Ianko
Telerik team
answered on 21 Apr 2015, 08:38 AM
Hello Dan,

RadEditor, by default, does not allow scripts in the content area. In order to be able to use script tags you need to disable both RemoveScripts and EncodeScript filters, as shown here—http://www.telerik.com/help/aspnet-ajax/editor-preventing-cross-site-scripting.html#custom-content-filters.

Additionally, the ConvertCharactersToEntities filter is also enabled by default. Therefore, the '>' or '<' inside a script tag would be converted to the corresponding entities. To stop this behavior, you need to disable this filter too:
RadEditor1.DisableFilter(EditorFilters.ConvertCharactersToEntities);

Regards,
Ianko
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Dan Ehrmann
Top achievements
Rank 1
answered on 21 Apr 2015, 02:04 PM
So, there is no way to allow scripts to be added in the editor, and to also use the ConvertCharactersToEntities filter - correct?
0
Ianko
Telerik team
answered on 22 Apr 2015, 06:42 AM
Hi Dan,

More accurately, in script tags special HTML characters, like <,>,&, etc., cannot be used if the filter is enabled.

Regards,
Ianko
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Editor
Asked by
Dan Ehrmann
Top achievements
Rank 1
Answers by
Dan Ehrmann
Top achievements
Rank 1
Ianko
Telerik team
Share this question
or