157239633: Spaces converted to plus when included in a dynamic link
See original GitHub issueDescribe your environment
- Android Studio version: 3.5.1
- Firebase Component: Dynamic links
- Component version: 19.0.0
Describe the problem
I’ve created a deep link with a query parameter that contains A + B
. The query parameter is url encoded before being passed to setLink()
:
FirebaseDynamicLinks.getInstance().createDynamicLink().setLink("https://example.appspot.com/?parameter=A%20%2B%20B")
When I later open this dynamic link the value of the parameter is not what I expect. In the onSuccess
method of the OnSuccessListener
the value of pendingDynamicLinkData.link
is:
https://example.appspot.com/?parameter=A+++B
Both spaces (%20) and pluses (%2b) are converted to +
when doing the URL decoding making it impossible to pass any spaces trough a dynamic link.
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (2 by maintainers)
Top Results From Across the Web
Firebase dynamic link shortner api converts all (spaces) %20 ...
This content type specifies that spaces are to be encoded as + , the reserved characters are to be escaped according to the...
Read more >URL links are breaking with spaces - Power Platform Community
The 'File Name' is not and will never be fixed. I'd like to add the dynamic content "Name" from the "When an item...
Read more >Deep link potential users to the right place inside your app
Convert mobile web users to native app users. With Dynamic Links, you can seamlessly transition users from your mobile website to the equivalent...
Read more >Spaces and Uppercase characters in URLs - SISTRIX
Spaces are not a valid part of URLs. They need to be converted to a special string For spaces, ... URL encoding: with...
Read more >urlencode - Manual - PHP
The returned URL from the shortener may be truncated if not encoded. ... here is the second parameter has spaces which urlencode converts...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As far as I know space is the only character where this happens. I think the problem comes from mixing
java.net.URLEncoder.encode()
withandroid.net.Uri.decode()
. The former “Translates a string into application/x-www-form-urlencoded format using a specific encoding scheme.” while the later percent encode all characters that are not unreserved characters, letters or numbers which including space and plus.Here’s an example of what happens when you encode using one scheme and decode using the other. Code:
Output:
The second to last line illustrate exactly the problem we are having here.
I’m not sure I agree with that completely. When doing percent encoding for URIs, like the Firebase deep links, spaces should be encoded as
%20
. This is explicitly mentioned in RFC 3986 which defines the format of URIs including how data in it should be encoded.The confusion around this comes from how browsers submits data from forms. Here they use the mime type
application/x-www-form-urlencoded
(which is not the same as percent encoded URIs).Wikipedia mentions the following:
This section refers to RFC1630, which does mention that space is encoded as plus. It does however also mention that plus signs need to be encoded
So regardless if the old standard, or the new standard is used, it should always be possible to both encode and decode a string containing both plus and space without loosing any of them.