Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roundtrip fails when max_nesting or max_bytesize is exceeded. #3

Open
bradland opened this issue Jul 14, 2016 · 0 comments
Open

Roundtrip fails when max_nesting or max_bytesize is exceeded. #3

bradland opened this issue Jul 14, 2016 · 0 comments

Comments

@bradland
Copy link

When limits defined by max_nesting or max_bytesize options are encountered, roundtrip operations fail. The problem is illustrated in the following script:

require 'lines'
require 'json'
require 'yaml'

class LinesRoundtrip
  ::DATA = {
    large: { "foo" => "b#{'a'*2048}r" },
    small: { "foo" => "bar" }
  }

  def run!
    roundtrip DATA[:small], Lines
    roundtrip DATA[:small], JSON
    roundtrip DATA[:small], YAML
    roundtrip DATA[:large], Lines
    roundtrip DATA[:large], JSON
    roundtrip DATA[:large], YAML
  end

  def roundtrip(data, serializer)
    puts "Attempting to roundtrip using #{serializer.name}:"
    puts "  #{data.inspect}"
    dump = serializer.dump(data)
    load = serializer.load(dump)

    puts "Ended up with:"
    puts "  #{load.inspect}"
    puts "---"
  end
end

begin
  if $0 == __FILE__
    LinesRoundtrip.new().run!
  end
rescue Interrupt
  # Ctrl^C
  exit 130
rescue Errno::EPIPE
  # STDOUT was closed
  exit 74 # EX_IOERR
end

When that script is run, Lines fails to roundtrip the large value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant