From 111a83d5b08fa6765addfa167ab7cb0e06e83017 Mon Sep 17 00:00:00 2001 From: Tatsuya Sato Date: Sun, 4 May 2025 01:00:47 +0900 Subject: [PATCH] Accepts files whose extension is not .docx or which does not have extension Fix #162 --- lib/docx/document.rb | 1 - spec/docx/document_spec.rb | 6 ------ 2 files changed, 7 deletions(-) diff --git a/lib/docx/document.rb b/lib/docx/document.rb index 4fe0ee1..c2a3759 100755 --- a/lib/docx/document.rb +++ b/lib/docx/document.rb @@ -29,7 +29,6 @@ def initialize(path_or_io, options = {}) # if path-or_io is string && does not contain a null byte if (path_or_io.instance_of?(String) && !/\u0000/.match?(path_or_io)) - raise Errno::EIO.new('Invalid file format') if !File.extname(path_or_io).eql?('.docx') @zip = Zip::File.open(path_or_io) else @zip = Zip::File.open_buffer(path_or_io) diff --git a/spec/docx/document_spec.rb b/spec/docx/document_spec.rb index 81d57b8..92eaafc 100755 --- a/spec/docx/document_spec.rb +++ b/spec/docx/document_spec.rb @@ -20,12 +20,6 @@ end context 'When reading a un-supported file' do - it 'should throw file not supported error' do - expect do - Docx::Document.open(@fixtures_path + '/invalid_format.pdf') - end.to raise_error(Errno::EIO, 'Input/output error - Invalid file format') - end - it 'should throw file not found error' do invalid_path = @fixtures_path + '/invalid_file_path.docx' expect do