Prevent <!DocType html> tag from being stripped

6 posts, 0 answers
  1. Mark Kucera
    Mark Kucera avatar
    84 posts
    Member since:
    Sep 2009

    Posted 25 Aug 2014 Link to this post

    It seems like no matter what i do, switching between HTML and code view removes the <!doctype> tag from my content.  I've recorded a video that demonstrates this behavior using your online demos. 

    http://youtu.be/G7xR036tRXQ?hd=1

    Is there a way to correct this behavior?

    Thanks!
    -Mark
  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 26 Aug 2014 Link to this post

    Hi Mark,

    I tried to reproduce the problem, but to no avail. Please examine this screencast and let me know if I am missing something important.

    Could you please test if you are able to reproduce the same behavior on your end using this online demo and get back to me with the exact steps to reproduce, so that I could be able to investigate it on my end?

    If this is happening only with isolated scenario, please prvide some details about the specific configuration of the RadEditor control that leads to the described behavior.

    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark Kucera
    Mark Kucera avatar
    84 posts
    Member since:
    Sep 2009

    Posted 26 Aug 2014 in reply to Ianko Link to this post

    Ok, so i figured out in your demo page that <!doctype html> is stripped out, but <!DOCTYPE html> is NOT stripped out.  I've confirmed our application also works as long as DOCTYPE is capitalized.  Do you know what that would be since HTML tags are case-insensitive?  Anything we can do to prevent?

    Thanks!
  5. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 27 Aug 2014 Link to this post

    Hi Mark,

    Thank you for getting back. to me.

    The RadEditor control supports only valid XHTML content and as per to validation requirements, the DOCTYPE declaration should be always upper case.

    I am unable to suggest a possible approach to let users add lower case DOCTYPE.

    More details about this matter is discussed in this Stackoverflow forum thread.

    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Mark Kucera
    Mark Kucera avatar
    84 posts
    Member since:
    Sep 2009

    Posted 27 Aug 2014 in reply to Ianko Link to this post

    Thanks for the information.  I actually had found and read that same post already.  There seems to be a lot of ambiguity about the correct casing requirements for that tag.  But it does appear to be the consensus that using capital doesn't ever hurt.  Now that I know what is happening I believe that I can correct for this using a custom filter.

    I've written custom filters before and this seems to be pretty straight forward. For anyone interested the filter code would look similar to this:

    function OnClientLoad(editor, args) {
        try {
            editor.get_filtersManager().add(new SymbolsCustomFilter());
            editor.get_filtersManager().add(new ImageAlignmentCustomFilter());
            editor.get_filtersManager().add(new HorizontalAlignCustomFilter());
            editor.get_filtersManager().add(new BrReplacementInEmptyTableCellFilter());
            editor.get_filtersManager().add(new XSSFilter());
            editor.get_filtersManager().add(new DocTypeFilter());
        }
        catch (e) {
            alert(e);
        }
    }
     
    DocTypeFilter = function () {
        DocTypeFilter.initializeBase(this);
        this.set_isDom(false);
        this.set_enabled(true);
        this.set_name("Doctype filter");
        this.set_description("This filter will correct any lowercase doctype tags found in the document.");
    }
     
    DocTypeFilter.prototype =
    {
        getDesignContent: function (content) {
            try {
                content = content.replace('<!doctype', '<!DOCTYPE');
            }
            catch (e) { }
     
            return content;
        },
     
        getHtmlContent: function (content) {
            try {
                content = content.replace('<!doctype', '<!DOCTYPE');
            }
            catch (e) { }
     
            return content;
        }
    }
     
    try {
        DocTypeFilter.registerClass('DocTypeFilter', Telerik.Web.UI.Editor.Filter);
    }
    catch (e)
    { }

    Regards,
    -Mark
  7. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 29 Aug 2014 Link to this post

    Hi Mark,

    Thank you for sharing this custom filter with the Telerik community.

    I believe that it will be really useful to other developers, encountered the same behavior.

    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

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