diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-12 09:01:28 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-12 09:01:28 +0000 |
commit | 77f3125567adc54b8a5534c2c1ded5a19100e8d5 (patch) | |
tree | c7da988289c6d95d798eec182fad806c622935e1 | |
parent | a11e25432bf68d87528537b0717f6f13519622eb (diff) | |
download | ruby-77f3125567adc54b8a5534c2c1ded5a19100e8d5.tar.gz |
rdoc/text.rb: fix infinite loop
* lib/rdoc/text.rb (expand_tabs): get rid of infinite loop with
CR. should check if substitution occurred too.
[ruby-dev:48813] [Bug #10732]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49223 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/rdoc/text.rb | 4 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_text.rb | 3 |
3 files changed, 11 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Mon Jan 12 18:01:24 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/rdoc/text.rb (expand_tabs): get rid of infinite loop with + CR. should check if substitution occurred too. + [ruby-dev:48813] [Bug #10732] + Mon Jan 12 16:45:46 2015 Seiei Higa <hanachin@gmail.com> * vm_method.c (rb_alias): raise a NameError when creating alias to diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index 3a58641ec1..606f15eb0e 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -68,11 +68,11 @@ module RDoc::Text expanded = [] text.each_line do |line| - line.gsub!(/^((?:.{8})*?)([^\t\r\n]{0,7})\t/) do + nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do r = "#{$1}#{$2}#{' ' * (8 - $2.size)}" r.force_encoding text.encoding if Object.const_defined? :Encoding r - end until line !~ /\t/ + end expanded << line end diff --git a/test/rdoc/test_rdoc_text.rb b/test/rdoc/test_rdoc_text.rb index b0c464a659..a69989d15d 100644 --- a/test/rdoc/test_rdoc_text.rb +++ b/test/rdoc/test_rdoc_text.rb @@ -56,6 +56,9 @@ class TestRDocText < RDoc::TestCase assert_equal('. .', expand_tabs(".\t\t."), 'dot tab tab dot') + + assert_equal('a a', + Timeout.timeout(1) {expand_tabs("\ra\ta")}, "carriage return") end def test_expand_tabs_encoding |