1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
Commit graph

17 commits

Author SHA1 Message Date
Sutou Kouhei
22ef4f6445 [ruby/csv] Revert "parser: fix a keep bug that some texts may be dropped unexpectedly"
This reverts commit 5c6523da0a.

This introduces another pbolem. We should try again later.

43a1d6fff1
2021-12-24 14:35:33 +09:00
Sutou Kouhei
002ce9f515 [ruby/csv] parser: use row separator explicitly
It will improve performance a bit. (But I haven't confirmed it yet...)

06a65b0302
2021-12-24 14:35:33 +09:00
Sutou Kouhei
4a5d372ca8 [ruby/csv] parser: fix a keep bug that some texts may be dropped unexpectedly
Ruby: [Bug #18245] [ruby-core:105587]

Reported by Hassan Abdul Rehman.

5c6523da0a
2021-12-24 14:35:33 +09:00
Sutou Kouhei
56a5ae9f52 [ruby/csv] Fix a bug that all of ARGF contents may not be consumed
GitHub: fix GH-228

Reported by Rafael Navaza. Thanks!!!

81f595b6a1
2021-12-24 14:35:33 +09:00
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.

cc317dd42d
2021-12-24 14:35:33 +09:00
rm155
ee948fc1b4 [ruby/csv] Add support for Ractor (https://github.com/ruby/csv/pull/218)
a802690e11
2021-10-24 05:57:33 +09:00
Sutou Kouhei
8ba98f83b0 [ruby/csv] Use "\n" for the default row separator on Ruby 3.0 or later
1f9cbc170e
2021-10-24 05:57:33 +09:00
Joakim Antman
7f3dd601c8 [ruby/csv] Changed line ending handling to consider the combination \r\n as a single entry when row is faulty (https://github.com/ruby/csv/pull/220)
29cef9ea9d
2021-10-24 05:57:33 +09:00
Sutou Kouhei
832b7f3c54 [ruby/csv] Add support for \r\n with skip_lines: /...$/ again
GitHub: fix GH-194

Reported by Josef Šimánek. Thanks!!!

fd86afe081
2020-11-24 09:33:55 +09:00
Sutou Kouhei
cf7e472ab4
[ruby/csv] test scanner: specify encoding explicitly
6e83a1de9c
2020-07-20 02:32:50 +09:00
Sutou Kouhei
814bfc8adc
[ruby/csv] Fix a parse bug when split character exists in middle of column value
GitHub: fix #115

Reported by TOMITA Masahiro. Thanks!!!

398b3564c5
2020-07-20 02:32:49 +09:00
Mike MacDonald
d57bc03ba9
[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

3b15d4a3e8
2020-07-20 02:32:49 +09:00
Sutou Kouhei
92df7d98b6
Import CSV 3.1.2 (#2547) 2019-10-12 14:03:21 +09:00
Kouhei Sutou
198281a71d [ruby/csv] Fix a bug that strip: true removes newlines
5540d35a30
2019-07-14 23:07:31 +09:00
kou
e3b6c7c7eb Import CSV 3.0.8
This includes performance improvements and backward incompatibility
fixes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-14 21:01:51 +00:00
kou
24b57b102c Upgrade CSV to 3.0.4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-25 06:49:59 +00:00
kou
e5d634260e Import CSV 3.0.2
This includes performance improvement especially writing. Writing is
about 2 times faster.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-23 07:00:35 +00:00