Defect #6054
closed
Error 500 on filenames with whitespace in git reposities
Added by Georg Lukas over 14 years ago.
Updated about 14 years ago.
Description
Getting a directory listing from GIT crashes Redmine with an internal server error when a file has whitespace in its name:
NoMethodError (private method `split' called for nil:NilClass):
/lib/redmine/scm/adapters/git_adapter.rb:93:in `lastrev'
/lib/redmine/scm/adapters/abstract_adapter.rb:193:in `call'
/lib/redmine/scm/adapters/abstract_adapter.rb:193:in `shellout'
/lib/redmine/scm/adapters/abstract_adapter.rb:191:in `popen'
/lib/redmine/scm/adapters/abstract_adapter.rb:191:in `shellout'
/lib/redmine/scm/adapters/abstract_adapter.rb:177:in `shellout'
/lib/redmine/scm/adapters/git_adapter.rb:92:in `lastrev'
/lib/redmine/scm/adapters/git_adapter.rb:77:in `entries'
/lib/redmine/scm/adapters/git_adapter.rb:65:in `each_line'
/lib/redmine/scm/adapters/git_adapter.rb:65:in `entries'
....
This is caused by inadequate quoting of path names in GitAdapter.lastrev(), which affects at least 0.8.4, but seems unfixed in 1.0rc and trunk as well. A patch fixing this issue is attached.
Files
Sorry Felix, your link requires a login so I can't test. Do you have filenames with whitespace or repository path/name with whitespace? My problem only occured with the former.
I'm running Debian stable with:
$ git --version
git version 1.5.6.5
Sorry, I thought it was public (which it should have been), it is public now.
I have a file whitespace filename.txt
in the repo, git version string is git version 1.7.1
.
Ah, now I see that it does not crash Redmine any more. However it does not display the revision and change information for that file. If you add another file without whitespace, I am pretty sure you will see its revision, author etc. columns. Could you please try to do so and compare the output with/without my patch?
The version of git on the other hand should not matter - it is solely an issue with file name quoting.
- Affected version (unused) changed from 0.8.4 to devel
- Affected version deleted (
0.8.4)
Ah, I now see what you mean and can confirm the bug on trunk.
Could you see if other places in the git adapter are concerned and maybe even write a test for that? Thanks!
From a quick glance the path quoting problem seems to affect GitAdapter.revisions()
as well. Other subtle but bad things will probably happen in GitAdapter.entries()
and GitAdapter.revisions()
when file names start with whitespace.
The adapter might also freak out badly if the repository directory contains spaces in its path - I see no quoting at all for target('')
.
Regarding the test, I fear I can not help you much - I have exactly zero coding experience in Ruby.
- Target version set to 1.0.2
- Status changed from New to Resolved
- Assignee set to Eric Davis
- % Done changed from 0 to 100
- Resolution set to Fixed
Committed in r4188. I found another issue if the file has leading or trailing whitespace, Felix said he will try to work on a fix (#6499).
- Status changed from Resolved to Closed
Also available in: Atom
PDF