Skip to content

Commit cc0d1ec

Browse files
Merge pull request #348 from ukolovda/name_with_leading_slash
Fix open error if sheet name lead from slash (i.e. "/xl/worksheets/sheet.xml").
2 parents 8ded0dc + f1bc6e6 commit cc0d1ec

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lib/roo/excelx.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def extract_worksheet_rels(entries, path)
363363
def extract_sheets_in_order(entries, sheet_ids, sheets, tmpdir)
364364
(sheet_ids & sheets.keys).each_with_index do |id, i|
365365
name = sheets[id]
366-
entry = entries.find { |e| e.name =~ /#{name}$/ }
366+
entry = entries.find { |e| "/#{e.name}" =~ /#{name}$/ }
367367
path = "#{tmpdir}/roo_sheet#{i + 1}"
368368
sheet_files << path
369369
@sheet_files << path
234 KB
Binary file not shown.

test/test_roo.rb

+5
Original file line numberDiff line numberDiff line change
@@ -2109,4 +2109,9 @@ def test_cleanup_on_error
21092109
with_each_spreadsheet(:name=>'non_existent_file', :ignore_errors=>true) do |oo|; end
21102110
assert_equal Dir.open(Dir.tmpdir).to_a, old_temp_files
21112111
end
2112+
2113+
def test_name_with_leading_slash
2114+
xlsx = Roo::Excelx.new(File.join(TESTDIR,'name_with_leading_slash.xlsx'))
2115+
assert_equal 1, xlsx.sheets.count
2116+
end
21122117
end # class

0 commit comments

Comments
 (0)