diff options
author | Koichi ITO <koic.ito@gmail.com> | 2020-06-04 12:08:05 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-07-20 02:32:52 +0900 |
commit | cee10c1b7033f4682b3f4c76220c0c190e70aa1a (patch) | |
tree | 17f341739f1f98fd9679b505de594914f6a9ccc6 /lib/csv | |
parent | 4e33a878793a5ced47a4f14b8a73cbc2795d97b7 (diff) | |
download | ruby-cee10c1b7033f4682b3f4c76220c0c190e70aa1a.tar.gz |
[ruby/csv] Fix an error for `CSV.open` (#131)
Follow up to https://github.com/ruby/csv/pull/130/files#r434885191.
This PR fixes `ArgumentError` for `CSV.open` when processing
invalid byte sequence in UTF-8.
https://github.com/ruby/csv/commit/a4b528c209
Diffstat (limited to 'lib/csv')
-rw-r--r-- | lib/csv/writer.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/csv/writer.rb b/lib/csv/writer.rb index 9243d23641..6c02d7473e 100644 --- a/lib/csv/writer.rb +++ b/lib/csv/writer.rb @@ -156,7 +156,7 @@ class CSV else field = String(field) # Stringify fields # represent empty fields as empty quoted fields - if (@quote_empty and field.empty?) or @quotable_pattern.match?(field) + if (@quote_empty and field.empty?) or (field.valid_encoding? and @quotable_pattern.match?(field)) quote_field(field) else field # unquoted field |