mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/csv] Do not loop forever when skip_lines regexp matches zero length with anchors (#110)
* Do not loop forever when skip_lines regexp matches zero length with anchors * Remove needless white spaces * Add missing eos check in skip_needless_lines * Simplify test https://github.com/ruby/csv/commit/3b15d4a3e8
This commit is contained in:
parent
b219cd5ac3
commit
d57bc03ba9
Notes:
git
2020-07-20 03:35:48 +09:00
2 changed files with 8 additions and 1 deletions
|
@ -769,7 +769,7 @@ class CSV
|
|||
def skip_needless_lines
|
||||
return unless @skip_lines
|
||||
|
||||
while true
|
||||
until @scanner.eos?
|
||||
@scanner.keep_start
|
||||
line = @scanner.scan_all(@not_line_end) || "".encode(@encoding)
|
||||
line << @row_separator if parse_row_end
|
||||
|
|
|
@ -102,4 +102,11 @@ class TestCSVParseSkipLines < Test::Unit::TestCase
|
|||
:skip_lines => /\A#/))
|
||||
end
|
||||
end
|
||||
|
||||
def test_empty_line_and_liberal_parsing
|
||||
assert_equal([["a", "b"]],
|
||||
CSV.parse("a,b\n",
|
||||
:liberal_parsing => true,
|
||||
:skip_lines => /^$/))
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue