summaryrefslogtreecommitdiff
path: root/lib/csv
diff options
context:
space:
mode:
authorSutou Kouhei <kou@clear-code.com>2023-06-26 14:29:26 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-06-28 16:37:10 +0900
commitd6d60d4287f58200cc3725d19cb503be70e7d724 (patch)
tree910c78dabb8fb1446907916db83c9ef1d89edc44 /lib/csv
parent539559d36e1355befd39c6964f3efd9dd3af4846 (diff)
[ruby/csv] Fix a bug that the same line is used multiple times
GitHub: fix https://github.com/ruby/csv/pull/279 It's happen when: * `keep_start`/`keep_{drop,back}` are nested. (e.g.: `strip: true, skip_lines: /.../`) * Row separator is `\r\n`. * `InputScanner` is used. (Small input doesn't use `InputScanner`) Reported by Gabriel Nagy. Thanks!!! https://github.com/ruby/csv/commit/183635ab56
Diffstat (limited to 'lib/csv')
-rw-r--r--lib/csv/parser.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/csv/parser.rb b/lib/csv/parser.rb
index 3b05132054..ed9297fe30 100644
--- a/lib/csv/parser.rb
+++ b/lib/csv/parser.rb
@@ -201,7 +201,8 @@ class CSV
# trace(__method__, :rescan, start, buffer)
string = @scanner.string
if scanner == @scanner
- keep = string.byteslice(start, string.bytesize - start)
+ keep = string.byteslice(start,
+ string.bytesize - @scanner.pos - start)
else
keep = string
end