file access in app builds invalid url by inserting %2F #234

Closed
opened 2020-06-03 23:31:26 +00:00 by 6543 · 9 comments
Member

Created By: @TheRealDarklord

Description - describe the bug / feature / suggestion in brief :

If I want to access any file or folder in one of my hosted repos I just get the message that my gitea version needs to be at least version 1.7 to use this feature. I am currently running 1.10 on my server.

If I open the log of gitea then I can see that the accessed api url contains an unneeded %!F(MISSING) (the urlencoded char "/"; see logs provided at the bottom, I marked it bold). I don't know where this is coming from, but this prevents the file to be found and so a 404 is issued. GitNex then interprets this as a non supported gitea version.

Expected behaviour - describe what should be the expected result :

I expect a valid request to load the file or directory content in the GitNex app.

GitNex version :

2.3.0

Gitea version :

1.10

Android version :

10

Logs - if any :

[ip] - - [10/Dec/2019:19:44:39 +0100] "GET /api/v1/repos/[group]/[repo]/contents/**%!F(MISSING)**diff.xml HTTP/1.1" 404 3731 "-" "okhttp/3.12.1"

[ip] - - [10/Dec/2019:19:45:12 +0100] "GET /api/v1/repos/[group]/[repo]/contents/**%!F(MISSING)**folder HTTP/1.1" 404 3731 "-" "okhttp/3.12.1

Created By: @TheRealDarklord ##### Description - describe the bug / feature / suggestion in brief : If I want to access any file or folder in one of my hosted repos I just get the message that my gitea version needs to be at least version 1.7 to use this feature. I am currently running 1.10 on my server. If I open the log of gitea then I can see that the accessed api url contains an unneeded %!F(MISSING) (the urlencoded char "/"; see logs provided at the bottom, I marked it bold). I don't know where this is coming from, but this prevents the file to be found and so a 404 is issued. GitNex then interprets this as a non supported gitea version. ##### Expected behaviour - describe what should be the expected result : I expect a valid request to load the file or directory content in the GitNex app. ##### GitNex version : 2.3.0 ##### Gitea version : 1.10 ##### Android version : 10 ##### Logs - if any : [ip] - - [10/Dec/2019:19:44:39 +0100] "GET /api/v1/repos/[group]/[repo]/contents/**%!F(MISSING)**diff.xml HTTP/1.1" 404 3731 "-" "okhttp/3.12.1" [ip] - - [10/Dec/2019:19:45:12 +0100] "GET /api/v1/repos/[group]/[repo]/contents/**%!F(MISSING)**folder HTTP/1.1" 404 3731 "-" "okhttp/3.12.1
6543 added this to the 2.3.2 milestone 2020-06-03 23:31:26 +00:00
6543 added the
🐛 Bug
label 2020-06-03 23:31:26 +00:00
6543 closed this issue 2020-06-03 23:31:26 +00:00
Owner

Thank you for reporting this. I will look into it as soon as possible.

Can you share the path to the file from browser exlcuding the url/domain part?

Thank you for reporting this. I will look into it as soon as possible. Can you share the path to the file from browser exlcuding the url/domain part?
Author
Member

Created By: @TheRealDarklord

The gitea paths for my examples are the following:

[host-address]/[group]/[repo]/src/branch/master/diff.xml
[host-address]/[group]/[repo]/src/branch/master/folder

As the name already states: the second one is a folder. These paths can be accessed via browser with no problems.

If I have to guess I would say that the %!F(MISSING) is added to address root path elements. But since the second one is a folder and the content cannot be listed, I cannot test if accessing elements inside a folder would work.

Created By: @TheRealDarklord The gitea paths for my examples are the following: [host-address]/[group]/[repo]/src/branch/master/diff.xml [host-address]/[group]/[repo]/src/branch/master/folder As the name already states: the second one is a folder. These paths can be accessed via browser with no problems. If I have to guess I would say that the %!F(MISSING) is added to address root path elements. But since the second one is a folder and the content cannot be listed, I cannot test if accessing elements inside a folder would work.
Owner

Yes, %2f is the problem here. Fixing that will solve folder and file view issue.

Yes, `%2f` is the problem here. Fixing that will solve folder and file view issue.
Owner

@TheRealDarklord can you send an email to gitnex@swatian.com. I have patched the issue and would like to share with you the test apk before go for the merge and release.

I do not have this issue at hand to properly test it, would need your actual help to test the app. :)

@TheRealDarklord can you send an email to gitnex@swatian.com. I have patched the issue and would like to share with you the test apk before go for the merge and release. I do not have this issue at hand to properly test it, would need your actual help to test the app. :)
Author
Member

Created By: @TheRealDarklord

You can send the apk to the email on my profile. I'll test it then.

Created By: @TheRealDarklord You can send the apk to the email on my profile. I'll test it then.
Owner

GitNex 2.3.1 is released which have this fix too, available now in play store. Will soon be on f-droid.

Please reopen this issue if 2.3.1 did not solve the issue for you.

GitNex 2.3.1 is released which have this fix too, available now in play store. Will soon be on f-droid. Please reopen this issue if 2.3.1 did not solve the issue for you.
Author
Member

Created By: @TheRealDarklord

Unfortunately this issue is not resolved with the latest app update (2.3.1).

I still get an 404 in the access_log and the %!F(MISSING)-Prefix is still there.

If I read your commit which should fix this right, it's assumed that the file name contains the double slash already and it will be replaced with a single slash. But since the file in my example is at top level it only as the one leading slash. I assume the resulting url is built like this:

"[gitea-instance-url]" + "[api-path-for-repo-contents-with-trailing-slash]" + "[file-with-leading-slash]"

[api-path-for-repo-contents-with-trailing-slash] = /api/v1/repos/[group]/[repo]/contents/
[file-with-leading-slash] = /diff.xml

So the double slash only exists in the resulting final URL to access the resource. Looks like the leading slash for the repository contents is unneccessary? This slash is also shown in the gitnex app at the top navigation bar if I select the file.
Else this or the trailing slash in the api path for the repository contents is unneccessary.

Created By: @TheRealDarklord Unfortunately this issue is not resolved with the latest app update (2.3.1). I still get an 404 in the access_log and the %!F(MISSING)-Prefix is still there. If I read your commit which should fix this right, it's assumed that the file name contains the double slash already and it will be replaced with a single slash. But since the file in my example is at top level it only as the one leading slash. I assume the resulting url is built like this: ``` "[gitea-instance-url]" + "[api-path-for-repo-contents-with-trailing-slash]" + "[file-with-leading-slash]" [api-path-for-repo-contents-with-trailing-slash] = /api/v1/repos/[group]/[repo]/contents/ [file-with-leading-slash] = /diff.xml ``` So the double slash only exists in the resulting final URL to access the resource. Looks like the leading slash for the repository contents is unneccessary? This slash is also shown in the gitnex app at the top navigation bar if I select the file. Else this or the trailing slash in the api path for the repository contents is unneccessary.
Owner

Ohh, sorry about the hassle.

Can you create a test account and send the details to gitnex@swatian.com. Please reproduce the same with that account and repository.

This way easy for us to find the cause of the pronlem.

Ohh, sorry about the hassle. Can you create a test account and send the details to gitnex@swatian.com. Please reproduce the same with that account and repository. This way easy for us to find the cause of the pronlem.
Author
Member

o wrong issue :(

o wrong issue :(
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitnex/GitNex#234
No description provided.