Permalink
Browse files

Fix crash completing directories without read access

Tested-by: Mark Somerville <ms@pccl.info> [F17, MRI 1.9.3]
Signed-off-by: Mark Somerville <mark@scottishclimbs.com>
  • Loading branch information...
1 parent 9083221 commit 6eace731868d97b9973760531c0f1e498ec0ca21 @Spakman Spakman committed Oct 13, 2012
Showing with 11 additions and 1 deletion.
  1. +1 −1 lib/rbreadline.rb
  2. +10 −0 test/test_filename_completion_proc.rb
View
@@ -1157,7 +1157,7 @@ def rl_filename_completion_function(text, state)
begin
@directory = Dir.new(@dirname)
- rescue Errno::ENOENT, Errno::ENOTDIR
+ rescue Errno::ENOENT, Errno::ENOTDIR, Errno::EACCES
end
# Now dequote a non-null filename.
@@ -66,4 +66,14 @@ def test_list_files_and_directories_with_spaces
def test_list_files_in_current_directory
assert_equal((Dir.entries(".") - %w( . .. )).sort, Readline::FILENAME_COMPLETION_PROC.call("").sort)
end
+
+ def test_listing_files_with_no_read_access
+ FileUtils.mkdir("test_no_access")
+ FileUtils.touch("test_no_access/123")
+ FileUtils.chmod(0333, "test_no_access")
+ assert_nil Readline::FILENAME_COMPLETION_PROC.call("test_no_access/")
+ ensure
+ FileUtils.chmod(0775, "test_no_access")
+ FileUtils.rm_r("test_no_access")
+ end
end

0 comments on commit 6eace73

Please sign in to comment.