When using the IPv6 address ::/0 in a firewall rule, we will get the Ruby symbol :":/0" as a parsed response. I was able to trace it down to Oj.load changing the string in parsed_json in entry_loader.rb.
I have to admit, I do not get the arguments of the Oj developers, either. If Oj.load('{"foo": ":"}') does not work, this looks broken. If I get them right, then using the defaultmode: :object is almost always the wrong thing to do. When parsing JSON data that was not generated with Oj, it seems we need to use mode: :compat.
Here's a minimal reproducing example:
require 'oj'
data = '{"foo": ["::/0"]}'
p "Input data is:"
p data
puts "\n"
p "Oj parsed result with default mode is:"
p Oj.load(data)
puts "\n"
p "Oj parsed result with compat mode is:"
p Oj.load(data, mode: :compat)
with the output:
"Input data is:"
"{\"foo\": [\"::/0\"]}"
"Oj parsed result with default mode is:"
{"foo"=>[:":/0"]}
"Oj parsed result with compat mode is:"
{"foo"=>["::/0"]}
When using the IPv6 address
::/0
in a firewall rule, we will get the Ruby symbol:":/0"
as a parsed response. I was able to trace it down toOj.load
changing the string inparsed_json
inentry_loader.rb
.To my understanding, this is probably related to this discussion: https://github.com/ohler55/oj/issues/285
I have to admit, I do not get the arguments of the Oj developers, either. If
Oj.load('{"foo": ":"}')
does not work, this looks broken. If I get them right, then using the defaultmode: :object
is almost always the wrong thing to do. When parsing JSON data that was not generated with Oj, it seems we need to usemode: :compat
.Here's a minimal reproducing example:
with the output: