Sha256: e28e8080c856060ba1aaa67a552931aeddfa71ef5e3458f402108e84945ce197

Contents?: true

Size: 1.16 KB

Versions: 20

Compression:

Stored size: 1.16 KB

Contents

====== Option +field_size_limit+

Specifies the \Integer field size limit.

Default value:
  CSV::DEFAULT_OPTIONS.fetch(:field_size_limit) # => nil

This is a maximum size CSV will read ahead looking for the closing quote for a field.
(In truth, it reads to the first line ending beyond this size.)
If a quote cannot be found within the limit CSV will raise a MalformedCSVError,
assuming the data is faulty.
You can use this limit to prevent what are effectively DoS attacks on the parser.
However, this limit can cause a legitimate parse to fail;
therefore the default value is +nil+ (no limit).

For the examples in this section:
  str = <<~EOT
    "a","b"
    "
    2345
    ",""
  EOT
  str # => "\"a\",\"b\"\n\"\n2345\n\",\"\"\n"

Using the default +nil+:
  ary = CSV.parse(str)
  ary # => [["a", "b"], ["\n2345\n", ""]]

Using <tt>50</tt>:
  field_size_limit = 50
  ary = CSV.parse(str, field_size_limit: field_size_limit)
  ary # => [["a", "b"], ["\n2345\n", ""]]

---

Raises an exception if a field is too long:
  big_str = "123456789\n" * 1024
  # Raises CSV::MalformedCSVError (Field size exceeded in line 1.)
  CSV.parse('valid,fields,"' + big_str + '"', field_size_limit: 2048)

Version data entries

20 entries across 20 versions & 4 rubygems

Version Path
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/csv-3.3.0/doc/csv/options/parsing/field_size_limit.rdoc
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/csv-3.3.0/doc/csv/options/parsing/field_size_limit.rdoc
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/csv-3.3.0/doc/csv/options/parsing/field_size_limit.rdoc
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/csv-3.3.0/doc/csv/options/parsing/field_size_limit.rdoc
csv-3.3.0 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.2.9 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.2.8 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.2.7 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.2.6 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.2.5 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.2.4 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.2.3 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.2.2 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.2.1 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.2.0 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.1.9 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.1.8 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.1.7 doc/csv/options/parsing/field_size_limit.rdoc
csv-3.1.6 doc/options/parsing/field_size_limit.rdoc
csv-3.1.5 doc/field_size_limit.rdoc