Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Raise an exception when unserialization fails due to a missing class

  • Loading branch information...
commit a4743960a09139c3bd4d72a8f3a72ade8f4add2f 1 parent 51ba66b
@mmangino mmangino authored
View
3  activerecord/lib/active_record/coders/yaml_column.rb
@@ -33,7 +33,8 @@ def load(yaml)
obj ||= object_class.new if object_class != Object
obj
- rescue ArgumentError, Psych::SyntaxError
+ rescue ArgumentError , Psych::SyntaxError => e
+ raise if e.to_s =~ /undefined class/
yaml
end
end
View
8 activerecord/test/cases/coders/yaml_column_test.rb
@@ -48,6 +48,14 @@ def test_load_swallows_yaml_exceptions
bad_yaml = '--- {'
assert_equal bad_yaml, coder.load(bad_yaml)
end
+
+ def test_load_doesnt_handle_undefined_class_or_module
+ coder = YAMLColumn.new
+ missing_class_yaml = '--- !ruby/object:DoesNotExistAndShouldntEver {}\n'
+ assert_raises(ArgumentError) do
+ coder.load(missing_class_yaml)
+ end
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.