summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authoradamroyjones <10088591+adamroyjones@users.noreply.github.com>2021-11-18 21:20:09 +0000
committerSutou Kouhei <kou@cozmixng.org>2021-12-24 14:35:33 +0900
commitc70dc3cafb29d89d0377677ead346495183db47e (patch)
tree7acd1af5074bd2e78ee0cb54af78e9224034abca /include
parent47c53af16872d61576184b0d6935fcf531564cc4 (diff)
[ruby/csv] Add handling for ambiguous parsing options (https://github.com/ruby/csv/pull/226)
GitHub: fix GH-225 With Ruby 3.0.2 and csv 3.2.1, the file ```ruby require "csv" File.open("example.tsv", "w") { |f| f.puts("foo\t\tbar") } CSV.read("example.tsv", col_sep: "\t", strip: true) ``` produces the error ``` lib/csv/parser.rb:935:in `parse_quotable_robust': TODO: Meaningful message in line 1. (CSV::MalformedCSVError) ``` However, the CSV in this example is not malformed; instead, ambiguous options were provided to the parser. It is not obvious (to me) whether the string should be parsed as - `["foo\t\tbar"]`, - `["foo", "bar"]`, - `["foo", "", "bar"]`, or - `["foo", nil, "bar"]`. This commit adds code that raises an exception when this situation is encountered. Specifically, it checks if the column separator either ends with or starts with the characters that would be stripped away. This commit also adds unit tests and updates the documentation. https://github.com/ruby/csv/commit/cc317dd42d
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5336
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions