Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Added support for filenames which are quoted (usually containing inte…

…rnational/unicode characters).
  • Loading branch information...
commit ee90922f3da3f67ef19853a0759c1d09860fe3b3 1 parent 96bf1ac
@gf3 gf3 authored
Showing with 2 additions and 1 deletion.
  1. +1 −0  lib/git/lib.rb
  2. +1 −1  lib/git/status.rb
1  lib/git/lib.rb
@@ -298,6 +298,7 @@ def ls_files
command_lines('ls-files', '--stage').each do |line|
(info, file) = line.split("\t")
(mode, sha, stage) = info.split
+ file = eval(file) if file =~ /^\".*\"$/ # This takes care of quoted strings returned from git
hsh[file] = {:path => file, :mode_index => mode, :sha_index => sha, :stage => stage}
2  lib/git/status.rb
@@ -89,7 +89,7 @@ def construct_status
@files[file] = {:path => file, :untracked => true} unless @files[file] || || ignore.include?(file)
# find modified in tree
@base.lib.diff_files.each do |path, data|
@files[path] ? @files[path].merge!(data) : @files[path] = data

5 comments on commit ee90922


eval is evil. This is the wrong way to do this


eval is the wrong way to do this. That introduces security problems. Why not simply remove the first and last character?


Hey, the reason I added the eval is because git returns a slash encoded string whereas Dir.glob, it appears, deals directly with the international characters, and that will fail during the comparison for finding untracked files. E.g. <pre> >> "Euge\314\201nie Eckler.jpg" == "Eugénie Eckler.jpg" => false <pre>


hmm ok. I just tested it, eval seems to be no problem because git properly escapes quotes etc. But using eval to remove escape sequences just does not feel right. Maybe there’s a better way to do it.


I agree, it isn’t ideal. Perhaps we could escape the filenames that Dir.glob returns?

Please sign in to comment.
Something went wrong with that request. Please try again.