ConvertCharactersToEntities and Scripts

5 posts, 0 answers
  1. Dan Ehrmann
    Dan Ehrmann avatar
    152 posts
    Member since:
    Jul 2004

    Posted 17 Apr 2015 Link to this post

    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?

  2. Dan Ehrmann
    Dan Ehrmann avatar
    152 posts
    Member since:
    Jul 2004

    Posted 17 Apr 2015 in reply to Dan Ehrmann Link to this post

    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 21 Apr 2015 Link to this post

    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.

     
  5. Dan Ehrmann
    Dan Ehrmann avatar
    152 posts
    Member since:
    Jul 2004

    Posted 21 Apr 2015 in reply to Ianko Link to this post

    So, there is no way to allow scripts to be added in the editor, and to also use the ConvertCharactersToEntities filter - correct?
  6. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 22 Apr 2015 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017