You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although the original issue was found in ActiveRecord, it can be shown more generally serializing a Hash:
{ 'key' => %{2013-04-08 11:45:33} }.to_yaml # ok
=> "---\nkey: '2013-04-08 11:45:33'\n"
{ 'key' => %{- 2013-04-08 11:45:33} }.to_yaml # ok
=> "---\nkey: ! '- 2013-04-08 11:45:33'\n"
{ 'key' => %{- a\n2013-04-08 11:45:33} }.to_yaml # error
TypeError: can't convert nil into Integer
from ..gems/psych-1.3.4/lib/psych/scalar_scanner.rb:111:in `utc'
from ..gems/psych-1.3.4/lib/psych/scalar_scanner.rb:111:in `parse_time'
# but if the date format parses correctly, it doesn't fail, but the string has been incorrectly converted to yaml:
{ 'key' => %{- a\n2013-04-08 11:45} }.to_yaml
=> "---\nkey: ! '- a\n\n 2013-04-08 11:45'\n"
It seems like the same date handling error in #82 but the real issue (question?) seems to be that the leading '- string\n' sequence is causing psych to try to interpret my text as yaml when in fact it should all be treated as a string literal.
Is this expected behaviour?
Especially in the ActiveRecord case, can we control such behaviour so that user-generated content doesn't unexpectedly break psych?
The text was updated successfully, but these errors were encountered:
I ran into this issue with psych 1.3.4 with ActiveRecord models where string attributes contained something that 'looks like' YAML.
Although the original issue was found in ActiveRecord, it can be shown more generally serializing a Hash:
It seems like the same date handling error in #82 but the real issue (question?) seems to be that the leading '- string\n' sequence is causing psych to try to interpret my text as yaml when in fact it should all be treated as a string literal.
Is this expected behaviour?
Especially in the ActiveRecord case, can we control such behaviour so that user-generated content doesn't unexpectedly break psych?
The text was updated successfully, but these errors were encountered: