From 58a3d27f30731af6c28eebc53f85997a060edf05 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Mon, 7 Jun 2010 13:53:14 -0700 Subject: Fix for #3949 and related Syck/Yaml quietly passes on undefined classes as strings, so that if objects of those classes are loaded and re-serialized they passthrough unmodified. While not technically correct, it's still the POLS behavior, and we now support it. --- lib/puppet/util/zaml.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/puppet/util/zaml.rb') diff --git a/lib/puppet/util/zaml.rb b/lib/puppet/util/zaml.rb index dcf0e1921..b0e22a3ff 100644 --- a/lib/puppet/util/zaml.rb +++ b/lib/puppet/util/zaml.rb @@ -121,7 +121,8 @@ class Object instance_variables.sort # Default YAML behavior end def zamlized_class_name(root) - "!ruby/#{root.name.downcase}#{self.class == root ? '' : ":#{self.class.name}"}" + cls = self.class + "!ruby/#{root.name.downcase}#{cls == root ? '' : ":#{cls.respond_to?(:name) ? cls.name : cls}"}" end def to_zaml(z) z.first_time_only(self) { @@ -231,7 +232,7 @@ class String when ( (self =~ /\A(true|false|yes|no|on|null|off|#{num}(:#{num})*|!|=|~)$/i) or (self =~ /\A\n* /) or - (self =~ /\s$/) or + (self =~ /[\s:]$/) or (self =~ /^[>|][-+\d]*\s/i) or (self[-1..-1] =~ /\s/) or (self =~ /[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\xFF]/) or -- cgit