Skip to content

Commit

Permalink
filter files that have non utf-8 characters in their filenames (#2626)
Browse files Browse the repository at this point in the history
Filter files that have non utf-8 characters in their filenames using valid_encoding?
  • Loading branch information
johrstrom committed Mar 3, 2023
1 parent 8d92233 commit 08c1928
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/dashboard/app/models/posix_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def directory?
def ls
path.each_child.map do |child_path|
PosixFile.stat(child_path)
end.select do |stats|
valid_encoding = stats[:name].to_s.valid_encoding?
Rails.logger.warn("Not showing file '#{stats[:name]}' because it is not a UTF-8 filename.") unless valid_encoding
valid_encoding
end.sort_by { |p| p[:directory] ? 0 : 1 }
end

Expand Down
4 changes: 4 additions & 0 deletions apps/dashboard/app/models/remote_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def ls
mode: "",
dev: 0,
}
end.select do |stats|
valid_encoding = stats[:name].to_s.valid_encoding?
Rails.logger.warn("Not showing file '#{stats[:name]}' because it is not a UTF-8 filename.") unless valid_encoding
valid_encoding
end.sort_by { |p| p[:directory] ? 0 : 1 }
end

Expand Down

0 comments on commit 08c1928

Please sign in to comment.