1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix serialization problem with YAML in 1.8.3

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2360 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Scott Barron 2005-09-27 09:25:17 +00:00
parent f5f7beb369
commit 76a7a52557
2 changed files with 4 additions and 17 deletions

View file

@ -1476,20 +1476,7 @@ module ActiveRecord #:nodoc:
def object_from_yaml(string)
return string unless string.is_a?(String)
if has_yaml_encoding_header?(string)
begin
YAML::load(string)
rescue Object
# Apparently wasn't YAML anyway
string
end
else
string
end
end
def has_yaml_encoding_header?(string)
string[0..3] == "--- "
YAML::load(string) rescue string
end
def clone_attributes(reader_method = :read_attribute, attributes = {})

View file

@ -754,9 +754,9 @@ class BasicsTest < Test::Unit::TestCase
end
def test_quote
content = "\\ \001 ' \n \\n \""
topic = Topic.create('content' => content)
assert_equal content, Topic.find(topic.id).content
author_name = "\\ \001 ' \n \\n \""
topic = Topic.create('author_name' => author_name)
assert_equal author_name, Topic.find(topic.id).author_name
end
def test_class_level_destroy