Skip to content

T419169 - invalid URL when opening external content#6537

Open
uwemartin-lgtm wants to merge 2 commits into
wikimedia:mainfrom
uwemartin-lgtm:T419169
Open

T419169 - invalid URL when opening external content#6537
uwemartin-lgtm wants to merge 2 commits into
wikimedia:mainfrom
uwemartin-lgtm:T419169

Conversation

@uwemartin-lgtm

Copy link
Copy Markdown
Contributor

What does this do?

Fixing incorrectly encoded URL which leads to incorrect navigation in browsers like DuckDuckGo

Why is this needed?

The problem with the code in LinkHandler is that if the url embedded in the messagePayload transferred to onMessage contains an encoded space character (%20). UriUtil.decodeURL will decode it and replace it with a real space character. This is then passed to onUrlClick where it is assigned to the local variable href. This local variable is then used to create an Uri which is assigned to the local variable uri. In this step, the space character is not encoded again. When passing uri to external browsers using onExternalLinkClicked, it depends on the functionality of the browser how the raw space character is interpreted. Apparently, DuckDuckGo (and potentially further browsers) process only the first part of the URI - ignoring the second part after the space character.

Problem
T419169_problem

Solution proposal
T419169_solution

I also added unit testing to verify if the correct content is created in LinkHandler.

Phabricator:
https://phabricator.wikimedia.org/T...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant