MakeUrlsAbsolute and IECleanAnchors

6 posts, 0 answers
  1. HSLaw
    HSLaw avatar
    153 posts
    Member since:
    Jan 2006

    Posted 16 Apr 2012 Link to this post

    Hi,

    I wonder if we can use MakeUrlsAbsolute and IECleanAnchors together?

    In our CMS edit page that use the editor, we need to make all URL Absolute. e.g. www.test.com.my/page1.aspx
    But when we set that filter, the Anchor will automatically have the path of the CMS edit page.

    E.g. 
    <A href="http://www.test.my/cms/content_editor.aspx?id=9f81dbc0-4491-4a65-af26-f52bd1c25596#sss">plugged </A>

    We try to set IECleanAnchors as well but not working.

    What is the correct way to make sure the URL is absolute but the anchor don;t embed the path of the CMS?

    Thanks.
  2. HSLaw
    HSLaw avatar
    153 posts
    Member since:
    Jan 2006

    Posted 17 Apr 2012 Link to this post

    Hi,

    I tried again and noticed it is actually not working if there are 2 querystrings and it is working with 1 querystring, as demonstrated here:

    http://www.ximnet.com.my/upload/telerik_editor_anchor_problem.swf

    Thanks.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 18 Apr 2012 Link to this post

    Hello,

    I am aware of this problem and it is already logged for fixing it in our PITS system. We will enhance the IECleanAnchorsFilter to strip absolute anchors with queries in the paths. Here you can find the PITS Issue: Public URL.

    You can solve the problem with the following code:
    <telerik:RadEditor runat="server" ID="RadEditor1" ContentFilters="DefaultFilters,MakeUrlsAbsolute"></telerik:RadEditor>
    <script type="text/javascript">
        Telerik.Web.UI.Editor.IECleanAnchorsFilter.prototype.getHtmlContent = function (content) {
            var basePageUrl = Telerik.Web.UI.Editor.Utils.escapeRegExSpecialChars(document.location.href);
            basePageUrl = basePageUrl.replace(/:/ig, "\\:").replace(/&/ig, "&amp;");
            var re = new RegExp("(<A[^<>]*?(href)\\s*=\\s*['\"])(" + basePageUrl + ")(\\#[^'\"]*?['\"][^>]*?>)", "i");
            var newContent = content.replace(re, "$1$4");
     
            return newContent;
        }
    </script>

    Best regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Dan Ehrmann
    Dan Ehrmann avatar
    151 posts
    Member since:
    Jul 2004

    Posted 10 Oct 2012 Link to this post

    Did this get fixed in a recent version? The PITS issue is not marked as being fixed, but the problem does not seem to occur in the demo anymore.
  6. Misho
    Admin
    Misho avatar
    129 posts

    Posted 15 Oct 2012 Link to this post

    Hello Dan,

    Currently the issue is still not fixed. Note that in order to reproduce it you need to have 2 query strings in the URL. For the time being you could use the code provided by Rumen to workaround the problem.

    All the best,
    Misho
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. Dan Ehrmann
    Dan Ehrmann avatar
    151 posts
    Member since:
    Jul 2004

    Posted 15 Oct 2012 Link to this post

    ok - thanx. In my situation, we do have multiple items in the query string. I am using Rumen's code, and it works well.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017