2 Replies Latest reply on Aug 5, 2009 12:20 PM by SilentChris

    Automatic URL escaping (# and % characters)

    SilentChris

      I'm having  a problem where links containing certain characters aren't working.  It seems that when anyone click on the link, it url encodes those characters at some level that I'm not controlling.  I've checked to make sure none of my code is actually escaping when I'm creating the <a> tags.

       

      This happens to both the # charcter (which would be any link pointing to an internal anchor on a page) and the % character (which means any link with a url encoded value).  The result is that the links just don't work.  Any url encoded value is double escaped.

       

      Has anyone else run into this problem?  Is there a way to fix it?

        • 1. Re: Automatic URL escaping (# and % characters)
          Flex harUI Adobe Employee

          encodeURI and decodeURI?

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: Automatic URL escaping (# and % characters)
            SilentChris Level 1

            I've tried these too, but if I have a link that has a url encoded character in it (say %2F for the "/" character), decodeURI doesn't handle it (http://livedocs.adobe.com/flex/3/langref/package.html#decodeURI%28%29).  I've also tried decodeURIComponent, which *does* decode it into a '/' character but then the link no longer works in the browser (since it's expecting a single url-encoded value - %2F)

             

            The problem seems to be that somewhere along the line, encodeURI might get called on the string but either

                 a) I've already encoded the character and encodeURI *does* encode the "%" character (which is already being used for an encoded character) or

                 b) I leave the character as is (after using decodeURIComponent to return it to its non-encoded form), but it's one of the characters that doesn't get encoded by encodeURI (but would get encoded by encodeURIComponent) - and I'm left with the unecoded version in my href value.

             

            Is there a way to either not have any encoding function get called when links are clicked on or have it call encodeURIComponent on the query string part of the URL instead of encodeURI?  (I understand that if you called encodeURIComponent on the whole URL, it would break the actual host/path part)