Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

%20 encoding as %2520 in LinkElement

New Here ,
Dec 14, 2011 Dec 14, 2011

I have a LinkElement in a RichEditableText's textflow. The link's href has encoded spaces in it (%20).

If I catch a click event and debug down to the LinkElement level the href still appears correct, however when it opens in new browser tab the url has been re-encoded
ie %20 is now %2520 - as the % sign has itself been encoded. Is there a way that I can stop this behavior?

Thanks

TOPICS
Text layout framework
4.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 14, 2011 Dec 14, 2011

Hi davidg84, You can uses real space in your URL, like "www.abc.com/bcd def.html", then TLF will help you handle your spaces.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 15, 2011 Dec 15, 2011

Thanks for your answer, my issue though is that users can enter in abritrary links, they may paste them from an address bar and be unaware of url encoding. What I'd prefer is for the url to be assumed correct and not encoded.

Is there somewhere I can intercept before the url gets encoded again?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 15, 2011 Dec 15, 2011

In your case, the only way is after you get users' input, handle the url by yourself, remove %20 and replace it with space, then pass the new url to TLF. Hope this helps.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 15, 2011 Dec 15, 2011
LATEST

I've addressed it as follows, when the RichEditableText renders, a function adds an event listener to each LinkElement, the handler does this:

if(event.flowElement && event.flowElement is LinkElement) {

                var linkElement:LinkElement = event.flowElement as LinkElement;

                var href:String = linkElement.href;

                // if its a mailto link, stop here

                if(href.indexOf("mailto:") == 0) {

                    return;

                }

               

                // Do not encode URL - navigate will handle it

                var url:URLRequest = new URLRequest(href);

               

                navigateToURL(url, linkElement.target);

                event.preventDefault();

                event.stopImmediatePropagation();

            }

           

        }

This seems to handle both encoded and unencoded urls. So i can leave the users input as they intend it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines