Copy and Paste Bug with Relative Link HREFs starting with /

2 posts, 0 answers
  1. mattzilla
    mattzilla avatar
    29 posts
    Member since:
    Sep 2006

    Posted 13 May 2010 Link to this post

    I've discovered a bug with RadEditor when copying and pasting a link, where the link's href starts with a slash. In Firefox, the pasted link is preceded by any number of ../ and part of the path removed, and in IE, the link is changed to an absolute path including the domain.

    Steps to reproduce.

    1. Visit:
    2. In the first paragraph, change the Sharepoint link's href to: /products/aspnet-ajax/sharepoint.aspx
    3. Copy the paragraph
    4. Paste the paragraph somewhere else in the editor
    5. View the new href of the Sharepoint link in the pasted paragraph


    Link href becomes: ../../../../products/aspnet-ajax/sharepoint.aspx

    Link href becomes:

    Expected result:

    Link to remain as /products/aspnet-ajax/sharepoint.aspx



  2. Rumen
    Rumen avatar
    12788 posts

    Posted 14 May 2010 Link to this post

    Hi Matt,

    This is a browser related behavior not related to RadEditor's source code.

    When copying and pasting a link or an image with a relative path in Internet Explorer, the browser automatically converts the path to absolute. The code below demonstrates how to attach to the OnClientPasteHtml event and strip the desired url path using the StripPathFilter content filter. The StripPathsFilter() method receives as a parameter an array of strings (devided by a white space) that will be stripped from the absolute path.

    <script type="text/javascript">
    function OnClientPasteHtml(sender, args)
        var commandName = args.get_commandName();
        var value = args.get_value();
        if (commandName == "Paste")
           // The StripPathsFilter() method receives as a parameter an array of strings (devided by a white space) that will be stripped from the absolute links.
            var domainName = "http://" +; //returns the hostname and port number of the current URL
            var filter = new Telerik.Web.UI.Editor.StripPathsFilter([domainName]); //strip the domain name from the absolute path
            var contentElement = document.createElement("SPAN");
            contentElement.innerHTML = value;
            var newElement = filter.getHtmlContent(contentElement);
            args.set_value(newElement.outerHTML);  //set the modified pasted content in the editor

    Please, note that the OnClientPasteHtml event fires the Paste command only when the StripFormattingOnPaste property is not set to "NoneSupressCleanMessage". In this case the editor does not process the pasted content and pastes it without modifications.

    The information above is taken from the description of the OnClientPasteHtml demo.

    All the best,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft R3 2016 release webinar banner
Back to Top