Skip to content

Commit ceb81dd

Browse files
committed
Do not attempt to read binary files
While RDoc had binary checks, it did not apply them at the appropriate location. Now binary checking is performed before attempting to convert a document to UTF-8 to avoid the warning. Fixes #189 Fixes #190 Fixes #195
1 parent 729b62a commit ceb81dd

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

History.rdoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* RDoc::Servlet no longer ignores extra directories from -d. Pull request
1616
#173 by Thomas Leitner
1717
* Fixed `rdoc --ri-site`. Bug #193 by Michal Papis.
18+
* RDoc no longer attempts to parse binary files. Bug #189 by postmodern,
19+
Bug #190 by Christoffer Lervåg, Bug #195 by Aaron Patterson
1820

1921
=== 4.0.0 / 2013-02-24
2022

lib/rdoc/rdoc.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ def parse_file filename
342342

343343
@stats.add_file filename
344344

345+
return if RDoc::Parser.binary? filename
346+
345347
content = RDoc::Encoding.read_file filename, encoding
346348

347349
return unless content

test/test_rdoc_rdoc.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,24 @@ def test_parse_file
162162
end
163163
end
164164

165+
def test_parse_file_binary
166+
@rdoc.store = RDoc::Store.new
167+
168+
root = File.dirname __FILE__
169+
binary_dat = File.expand_path 'binary.dat', root
170+
171+
@rdoc.options.root = Pathname root
172+
173+
out, err = capture_io do
174+
Dir.chdir root do
175+
assert_nil @rdoc.parse_file 'binary.dat'
176+
end
177+
end
178+
179+
assert_empty out
180+
assert_empty err
181+
end
182+
165183
def test_parse_file_page_dir
166184
@rdoc.store = RDoc::Store.new
167185

0 commit comments

Comments
 (0)