From 37f3efa29d56142a117a9197d5af9838967958fb Mon Sep 17 00:00:00 2001 From: NAKAMURA Usaku Date: Mon, 31 May 2021 23:44:23 +0900 Subject: [PATCH] [PATCH] merge revision(s) a7f5d6ab88 c9ab8fe2 [Backport#17877] a fix of RDoc for CVE-2021-31799 Gbp-Pq: Name CVE-2021-31799.patch --- lib/rdoc/rdoc.rb | 2 +- test/rdoc/test_rdoc_rdoc.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb index 4b74646..2549b20 100644 --- a/lib/rdoc/rdoc.rb +++ b/lib/rdoc/rdoc.rb @@ -439,7 +439,7 @@ The internal error was: files.reject do |file| file =~ /\.(?:class|eps|erb|scpt\.txt|ttf|yml)$/i or (file =~ /tags$/i and - open(file, 'rb') { |io| + File.open(file, 'rb') { |io| io.read(100) =~ /\A(\f\n[^,]+,\d+$|!_TAG_)/ }) end diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index 793580d..775ba65 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -335,6 +335,19 @@ class TestRDocRDoc < RDoc::TestCase end end + def test_remove_unparseable_CVE_2021_31799 + omit 'for Un*x platforms' if Gem.win_platform? + temp_dir do + file_list = ['| touch evil.txt && echo tags'] + file_list.each do |f| + FileUtils.touch f + end + + assert_equal file_list, @rdoc.remove_unparseable(file_list) + assert_equal file_list, Dir.glob('*') + end + end + def test_setup_output_dir Dir.mktmpdir {|d| path = File.join d, 'testdir' -- 2.30.2