1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib
adamroyjones c70dc3cafb [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
2021-12-24 14:35:33 +09:00
..
benchmark [ruby/benchmark] Freeze VERSION 2021-12-18 08:38:58 +09:00
bundler Merge RubyGems-3.3.2 and Bundler-2.3.2 2021-12-24 10:35:31 +09:00
cgi [ruby/cgi] Extract CGI::Session#new_store_file 2021-12-15 08:24:41 +09:00
csv [ruby/csv] Add handling for ambiguous parsing options (https://github.com/ruby/csv/pull/226) 2021-12-24 14:35:33 +09:00
delegate [ruby/delegate] gemspec: Drop unused executables directives 2021-10-22 19:48:22 +09:00
did_you_mean Revert the commits for did_you_mean 2021-12-23 10:09:10 +09:00
drb [ruby/drb] Bump up drb version to 2.1.0 2021-10-14 21:14:35 +09:00
erb
error_highlight [ruby/error_highlight] Bump version 2021-12-23 12:56:07 +09:00
forwardable [ruby/forwardable] gemspec: Explicitly empty the executables list 2021-04-21 20:41:52 +09:00
getoptlong [ruby/getoptlong] gemspec: Drop executables directives 2021-07-28 13:32:32 +09:00
irb [ruby/irb] irb_info codepage mismatch 2021-12-24 10:32:14 +09:00
logger [ruby/logger] Bump version to 1.5.0 2021-12-20 18:01:50 +09:00
net [ruby/net-http] gemspec: Drop unused directive "executables" 2021-11-17 19:09:14 +09:00
observer
open3 Fixed filename for Open3::VERSION 2021-12-09 19:48:22 +09:00
optparse [ruby/optparse] Moved rdoc files to doc/optparse 2021-04-11 09:03:36 +09:00
ostruct
pstore
racc [ruby/racc] Fix a private method name 2021-11-04 08:58:45 +09:00
random [ruby/securerandom] Use String#unpack1 2021-12-14 11:59:22 +09:00
rdoc [ruby/rdoc] Resolve class and method of the same name correctly 2021-12-09 18:16:05 +09:00
reline [ruby/reline] Determine 1st char or 2nd char of surrogate pair correctly 2021-12-24 13:57:46 +09:00
rinda [ruby/rinda] Bump up rinda version to 0.1.1 2021-10-21 21:02:37 +09:00
rubygems Merge RubyGems-3.3.2 and Bundler-2.3.2 2021-12-24 10:35:31 +09:00
set [ruby/set] Bump the version to 1.0.2 2021-11-16 20:55:33 +09:00
singleton
timeout
unicode_normalize Update lib/unicode_normalize/tables.rb to Unicode version 13.0.0 2021-07-08 14:45:03 +09:00
uri [ruby/uri] URI#HTTP#origin and URI#HTTP#authority (https://github.com/ruby/uri/pull/30) 2021-10-22 19:48:36 +09:00
weakref
yaml [ruby/yaml] Bump up yaml version to 0.2.0 2021-10-14 20:16:04 +09:00
abbrev.gemspec [ruby/abbrev] gemspec: Explicitly empty executables list 2021-04-21 20:39:04 +09:00
abbrev.rb
base64.gemspec [ruby/base64] Bump up base64 version to 0.1.1 2021-10-14 20:41:15 +09:00
base64.rb [ruby/base64] Avoid unnecessary string duplication 2021-09-27 15:23:25 +09:00
benchmark.rb [ruby/benchmark] Add comment about terminating newline in captions; fix test method name. 2021-04-22 11:51:37 +09:00
bundler.rb Merge RubyGems-3.3.0 and Bundler-2.3.0 2021-12-21 15:27:05 +09:00
cgi.rb [ruby/cgi] Bump version 2021-11-24 19:59:00 +09:00
csv.rb [ruby/csv] Add handling for ambiguous parsing options (https://github.com/ruby/csv/pull/226) 2021-12-24 14:35:33 +09:00
delegate.rb
did_you_mean.rb Revert the commits for did_you_mean 2021-12-23 10:09:10 +09:00
drb.rb
English.gemspec [ruby/English] gemspec: Remove unused "executables" configuration 2021-12-09 19:28:53 +09:00
English.rb
erb.gemspec
erb.rb [ruby/erb] Document that <% # doesn't work 2021-05-05 23:13:27 -07:00
error_highlight.rb Rename error_squiggle to error_highlight 2021-06-29 23:45:49 +09:00
fileutils.gemspec
fileutils.rb [ruby/fileutils] Bump up fileutils version to 1.6.0 2021-10-21 20:14:57 +09:00
find.gemspec [ruby/find] Bump up find version to 0.1.1 2021-10-14 20:26:15 +09:00
find.rb [ruby/find] Add Errno::EINVAL to list of ignored errors 2021-07-27 21:20:31 +09:00
forwardable.rb Prefer qualified names under Thread 2021-06-29 11:41:10 +09:00
getoptlong.rb [ruby/getoptlong] RDoc: escape to avoid links to the word Set 2021-07-28 13:32:33 +09:00
ipaddr.gemspec [ruby/ipaddr] Bump version to 1.2.3 2021-11-16 21:04:46 +09:00
ipaddr.rb [ruby/ipaddr] Fix include? and ipv4_mapped to allow drb tests to pass 2021-10-11 13:50:54 +09:00
irb.rb [ruby/irb] Check colorize option correctly to clear char attr and don't use it for tests 2021-12-21 15:50:32 +09:00
logger.rb [ruby/logger] Replace "iff" with "if and only if" 2021-04-20 21:19:41 +09:00
mkmf.rb Prefer flat_map 2021-12-10 18:39:48 +09:00
mutex_m.gemspec
mutex_m.rb [ruby/mutex_m] Make VERSION shareable 2021-10-22 19:49:34 +09:00
observer.rb
open-uri.gemspec [ruby/open-uri] gemspec: This gem exposes 0 executables 2021-12-09 19:28:54 +09:00
open-uri.rb Guard for the ftp protocol feature of OpenURI 2021-05-27 14:42:11 +09:00
open3.rb [ruby/open3] Update to match JRuby 9.4 2021-12-09 19:28:54 +09:00
optionparser.rb
optparse.rb [ruby/optparse] Bump up optparse version to 0.2.0 2021-10-21 21:01:34 +09:00
ostruct.rb [ruby/ostruct] Bump version to 0.5.2 2021-12-08 14:47:46 -05:00
pp.gemspec [ruby/pp] Bump version to 0.3.0 2021-12-20 12:44:31 +09:00
pp.rb [ruby/pp] [DOC] Update for PP.width_for [Feature #12913] 2021-12-23 18:00:56 +09:00
prettyprint.gemspec [ruby/prettyprint] Bump up prettyprint version to 0.1.1 2021-10-21 21:05:39 +09:00
prettyprint.rb
pstore.rb
racc.rb
rdoc.rb
readline.gemspec Update the latest version of readline.gemspec 2021-07-29 16:20:10 +09:00
readline.rb [ruby/readline] Suppress constant redefinition warning 2021-11-29 18:50:27 +09:00
reline.rb [ruby/reline] Finalize when exception occurred 2021-12-21 00:49:03 +09:00
resolv-replace.gemspec [ruby/resolv-replace] gemspec: Drop executables directive 2021-07-28 13:32:33 +09:00
resolv-replace.rb
resolv.gemspec [ruby/resolv] Bump version to 0.2.1 2021-07-28 13:32:33 +09:00
resolv.rb [ruby/resolv] Fix confusion of received response message 2021-05-11 12:37:34 +09:00
ruby2_keywords.gemspec Adjust the release version of ruby2_keywords 2021-07-16 13:50:15 +09:00
rubygems.rb Merge RubyGems-3.3.2 and Bundler-2.3.2 2021-12-24 10:35:31 +09:00
securerandom.gemspec [ruby/securerandom] Drop support for old ruby versions 2021-12-14 11:59:20 +09:00
securerandom.rb [ruby/securerandom] Split Random::Formatter from SecureRandom [Feature #18190] 2021-12-09 20:26:44 +09:00
set.rb [ruby/set] Make Set#pretty_print IRB::ColorPrinter friendly 2021-09-28 17:37:41 +09:00
shellwords.gemspec
shellwords.rb
singleton.rb
tempfile.gemspec [ruby/tempfile] Bump up tempfile version to 0.1.2 2021-10-19 20:55:55 +09:00
tempfile.rb Small grammar fixes 2021-09-01 09:15:57 +09:00
time.gemspec [ruby/time] Bump up time version to 0.2.0 2021-10-14 21:14:35 +09:00
time.rb Revert "disable shareable_constant_value for CI" 2021-04-26 22:46:51 +09:00
timeout.rb [ruby/timeout] Bump up timeout version to 0.2.0 2021-10-14 20:12:29 +09:00
tmpdir.gemspec
tmpdir.rb [ruby/tmpdir] [DOC] Fix syntax in example code [ci skip] 2021-11-11 10:37:35 +09:00
tsort.gemspec
tsort.rb
un.gemspec [ruby/un] Bump version to 0.2.0 2021-09-28 17:36:41 +09:00
un.rb [ruby/un] Use STDIN if no arguments 2021-08-24 18:02:44 +09:00
uri.rb Fix test failure for parallel testing 2021-07-27 17:34:13 +09:00
weakref.rb
yaml.rb