tomnomnom / gron

Make JSON greppable!
MIT License
13.88k stars 329 forks source link

gron produces output ungron can't process #46

Open jhnc opened 6 years ago

jhnc commented 6 years ago

It is unsafe to use a gron | ungron pipeline. The gron from gron-linux-amd64-0.5.2.tgz seems to have a 65535 byte limit on input to gron --ungron which does not match the output limit of gron:

$ perl -e 'print q({"blob":").(q(x) x 1000000000).qq("}\n)'|gron|sed 's/xx*/.../'|gron --ungron
{
  "blob": "..."
}
$ perl -e 'print q({"blob":").(q(x) x 1000000000).qq("}\n)'|gron|perl -nle 'print length'
10
1000000015
$ perl -e 'print q({"blob":").(q(x) x 65521).qq("}\n)'|gron|perl -nle 'print length'
10
65536
$ perl -e 'print q({"blob":").(q(x) x 65521).qq("}\n)'|gron|gron --ungron
failed to read input statements
$ perl -e 'print q({"blob":").(q(x) x 65520).qq("}\n)'|gron|perl -nle 'print length'
10
65535
$ perl -e 'print q({"blob":").(q(x) x 65520).qq("}\n)'|gron|gron --ungron|sed 's/xx*/.../'
{
  "blob": "..."
}
tomnomnom commented 6 years ago

Hi @jhnc!

Thanks for reporting this! And sorry I've not responded until now!

This is definitely a problem that needs to be sorted. Hopefully I'll have a fix for it soon :)