Skip to content
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

Browsers compatibility issues: Files with [ ] or ( ) in the name do have incorrectly encoded hyperlink in "raw" link. #1375

Closed
TomaszSzt opened this issue Sep 10, 2021 · 9 comments

Comments

@TomaszSzt
Copy link
Contributor

Steps to reproduce
1.Create a repository
2.Push a file named like, for an example "Px-[My file title].txt"
3.Enter the GITBlit page with this file, regardless if through commit or through the tree.
4.Find a "Raw" link to that file. Observe it will be looking like:
../../raw/somethi.git/9533e7971509d8476a9845d8fc31707abee9248c/Px-[My file title].tx

Notice that all un-allowed URL characters are NOT escaped. This includes spaces and [ ] brackets.
Click it in Firefox or Edge.
Observe Server Error.
Notice that browsers DID escape correctly spaces but DID NOT escape brackets. I think they should, but they did not.

5.Manually escape all characters using %20 for space %5A for [ and %5D for ] in browser address bar and tap enter.
6.Observe that server correctly responds to that link.

Wokaround

The only workaround to get raw file with such content through web interface is to download zipped repository.

Recomendation

All hyperlinks generated by GITBLIT should be valid, correctly escaped URLs.

Best regards,
Tomasz Sztejka

@flaix
Copy link
Member

flaix commented Oct 16, 2021

While I agree that the brackets could be escaped, I cannot reproduce an error. Which exact environment (OS/Browser) did you use?

I tested this under macOS with Firefox 92.0.1, Chrome 94.0.4606.81 and Safari 14 as well as under Linux with Firefox 93.0 and Chrome 94.0.4606.71. I never got en error but was always able to see the raw file.

@TomaszSzt
Copy link
Contributor Author

TomaszSzt commented Oct 20, 2021

Sorry for a delay, I was not monitoring this issue for a while.

I can still reproduce it every time and on every machine I checked at my work-place. It doesn't mean much because we were running a mass upgrade recently and all machines are fairly identical, but it shows that it is not a single seat configuration problem.

Windows 10, Firefox 93.0, GitBlit 1.8.0. No Firefox extensions were installed at the moment when the bug was encountered for a first time.

Sever page scree-shot:

gitblit-info

The html snippet for this link:

	<div class="page_nav2">
		<a href="../../../blame/E%2FE-13090-Czujka_smrodu.git/ticket%2F1/myfile%20%5B%20my%20wife%20%5D.txt">blame</a> | <a href="../../../history/E%2FE-13090-Czujka_smrodu.git/ticket%2F1/myfile%20%5B%20my%20wife%20%5D.txt">history</a> | <a href="../../../raw/E/E-13090-Czujka_smrodu.git/ticket!1/myfile [ my wife ].txt">raw</a>
	</div>	

You will notice, that the raw link is NOT escaped at all, while blame and history links ARE escaped.

Server response:

Error
Sorry, the requested resource /myfile%20[%20my%20wife%20].txt was not found in ticket/1.

The same problem can be reproduced in Edge 94.0.992.50

I did NOT test it with Gitblit 1.9.0 because I could not find any mention about this kind of a problem in a change log and updating a server is a risk I would like to avoid.

@flaix
Copy link
Member

flaix commented Oct 20, 2021

Yes, the raw link is not escaped, I just could not reproduce this problem, as the browsers do not mind. I will try this under Windows 10.

@flaix
Copy link
Member

flaix commented Oct 21, 2021

Interestingly, this seems to only occur with files that have a combination of spaces and brackets in the name. I was able to reproduce it with the exact filename of yours. A file with just brackets or just spaces does not pose a problem.

@flaix flaix added Status-Verified A bug could be reproduced. and removed Status-CanNotReproduce labels Oct 21, 2021
@TomaszSzt
Copy link
Contributor Author

Interestingly, this seems to only occur with files that have a combination of spaces and brackets (...)

Ha! I never tested another combination. Good to know that.

@flaix
Copy link
Member

flaix commented Oct 23, 2021

This seems to happen when both spaces and brackets are in a file name. I could not find a specific pattern or combination.
The browser escapes spaces everywhere. While file names with spaces without brackets reach the servlet unescaped, this is not true when there are also brackets in the path. I guess that Jetty has some weird rule about when to treat spaces how. Might be interesting to try this with Gitblit in a Tomcat.

@flaix
Copy link
Member

flaix commented Oct 24, 2021

I take it you use Gitblit GO? I have fixed this in PR #1383 but would still have to check how this behaves in an application server and if anything breaks.

@flaix flaix added this to the 1.9.2 milestone Oct 24, 2021
@TomaszSzt
Copy link
Contributor Author

I take it you use Gitblit GO? (...)
Possibly yes. That think where the GitBlit runs just stand-alone without any other server software needed. Just get Java, unzip and start.

Thanks for fix, now I will have a good reason to update when the next release will be officially ready, tested and stable.

@flaix
Copy link
Member

flaix commented Oct 25, 2021

Ya, well, I can give you officially ready, I don't know about tested and stable. I wish I had a way to release thoroughly tested builds, but as things are right now, I don't have the resources for that. And I have no idea how many people still use Gitblit, so how much testing it gets in the field. I do try to keep it as stable as possible.

@flaix flaix closed this as completed in f1b150b Oct 26, 2021
@flaix flaix added Status-Fixed and removed Priority-Medium Status-Verified A bug could be reproduced. labels Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants