summaryrefslogtreecommitdiff
path: root/lib/yaml/rubytypes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/yaml/rubytypes.rb')
-rw-r--r--lib/yaml/rubytypes.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb
index 92aee82dae..b2ac615849 100644
--- a/lib/yaml/rubytypes.rb
+++ b/lib/yaml/rubytypes.rb
@@ -295,19 +295,20 @@ class String
if complex
if self.is_binary_data?
out.binary_base64( self )
+ elsif self =~ /^ |#{YAML::ESCAPE_CHAR}| $/
+ complex = false
else
out.node_text( self )
end
- else
+ end
+ if not complex
ostr = if out.options[:KeepValue]
self
elsif empty?
"''"
- elsif YAML.detect_implicit( self ) != 'str'
+ elsif self =~ /^[^#{YAML::WORD_CHAR}]|#{YAML::ESCAPE_CHAR}|[#{YAML::SPACE_INDICATORS}]( |$)| $|\n|\'/
"\"#{YAML.escape( self )}\""
- elsif self =~ /#{YAML::ESCAPE_CHAR}|[#{YAML::SPACE_INDICATORS}] |\n|\'/
- "\"#{YAML.escape( self )}\""
- elsif self =~ /^[^#{YAML::WORD_CHAR}]/
+ elsif YAML.detect_implicit( self ) != 'str'
"\"#{YAML.escape( self )}\""
else
self