Skip to content

Commit 3a3c850

Browse files
+review changes
1 parent 0fee931 commit 3a3c850

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/docx/document.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def initialize(path_or_io, options = {})
2525

2626
# if path-or_io is string && does not contain a null byte
2727
if (path_or_io.instance_of?(String) && !/\u0000/.match?(path_or_io))
28+
raise Errno::EIO.new('invalid file format') if !File.extname(path_or_io).eql?('.docx')
2829
@zip = Zip::File.open(path_or_io)
2930
else
3031
@zip = Zip::File.open_buffer(path_or_io)
@@ -37,8 +38,6 @@ def initialize(path_or_io, options = {})
3738
@doc = Nokogiri::XML(@document_xml)
3839
load_styles
3940
yield(self) if block_given?
40-
rescue Zip::Error => e
41-
raise 'File not supported'
4241
ensure
4342
@zip.close unless @zip.nil?
4443
end

0 commit comments

Comments
 (0)