-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update ReadMe to include Uri.encode in examples #86
Comments
Just to be clear, I know I can use: I'm just concerned if there are any other special characters that are not handled since a full URLEncode appears to fail so is it something in between or is it just spaces? |
That encoding should work. But in order to download a file with spaces in the name I need to use:
And then:
Where a_remoteFilePath is equal to something like /folder/AAA Read Me.txt Otherwise the exception is thrown. Has anyone had success getting a file name that includes unescaped spaces? |
You always have to escape spaces. WebDav boils in the end down to regular urls and there are no whitespaces allowed. e.g. this is for uploading / downloading a file "com android chorme 20377014317.split.config.en.apk" in folder "__saf": http://10.0.2.2/nc/remote.php/webdav/___saf/com%20android%20chrome%20377014317.split.config.en.apk From help:
|
Yes I understand space must always be encoded. The question is why do I need to encode them in my code and the library does not do it. For example if I do these:
The log output is this:
So I just don't understand why the I need to replace the spaces to make it work. Can you tell me where in the code the library encodes the URL ? |
So what I am trying to understand is that since I would have expected either I need to encode the URL before setting it or I don't need to encode it because the library handles it but I just never expected I need to handle only the spaces explicitly in my code. It just seems odd. |
So I think there is a broader issue here. Say I have a folder on my drive and it is named |
OK I think now I have understood your answer. When I do
It actually needs to be:
So I am responsible to encode the URL but must exclude the slash (/) from being encoded. I will update the read me file to make this obvious to people like me. |
The reference I linked to is nextcloud-android-library, which is not used in SSO. Thank you for updating the readme 🎉 |
No worries. I thought I may need to encode the URL but what I did not understand was that I also needed to allow the slashes. I had just done |
@burningthumb Thanks Rob for pointing this out and for including it in your PR. I think your question regarding "why do I have to do this and why isn't the sso library taking care of it" is a valid question. I didn't encounter any cases where this was a problem during the development of this library as my endpoints never contained any whitespaces (for the nextcloud news app). @tobiasKaminsky I think we should do the url encoding in the sso library when calling |
There is a possible problem of a double encode if you do it in the |
Nice idea 👍 |
Wow, lot's of text. I read the thread and to summarize the key question is:
It seems like a quick fix (even considering some breaking changes), so I just tried to replace ncr.url = url; with ncr.url = Uri.encode(url); This broke the sample app (using My recommendation is to keep the behavior as it is, but add some |
Summarizing:
I'll therefore close this issue, feel free to reopen in case of new information or ideas 🙂 |
I am using the webdav GET method to download files.
If my url has spaces in it, like this:
remote.php/webdav/folder/AAA HOWTO.txt
When I try to
performNetworkRequest()
, it throws an exceptionI tried to encode the URL using URLEncoder but then I get a error for every URL regardless of spaces.
Any ideas on what kind of URL should be assigned to the URL field of the network request and how it should be properly escaped to not throw an exception based on spaces or other special characters?
The text was updated successfully, but these errors were encountered: