Skip to content

Commit 811c86f

Browse files
committed
Fixed infinite loop with CR #339
1 parent 01c805c commit 811c86f

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

History.rdoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
=== 4.2.1
2+
3+
* Bug fixes
4+
* Fixed infinite loop with CR #339
5+
16
=== 4.2.0 / 2014-12-06
27

38
* Major enhancements

lib/rdoc/text.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ def expand_tabs text
6868
expanded = []
6969

7070
text.each_line do |line|
71-
line.gsub!(/^((?:.{8})*?)([^\t\r\n]{0,7})\t/) do
71+
nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do
7272
r = "#{$1}#{$2}#{' ' * (8 - $2.size)}"
7373
r.force_encoding text.encoding if Object.const_defined? :Encoding
7474
r
75-
end until line !~ /\t/
75+
end
7676

7777
expanded << line
7878
end

test/test_rdoc_text.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ def test_expand_tabs
5656

5757
assert_equal('. .',
5858
expand_tabs(".\t\t."), 'dot tab tab dot')
59+
60+
assert_equal('a a',
61+
Timeout.timeout(1) {expand_tabs("\ra\ta")}, "carriage return")
5962
end
6063

6164
def test_expand_tabs_encoding

0 commit comments

Comments
 (0)