summaryrefslogtreecommitdiff
path: root/ext/psych
diff options
context:
space:
mode:
Diffstat (limited to 'ext/psych')
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index 9cbc05df4a..d420abd64e 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -231,15 +231,18 @@ module Psych
plain = false
quote = false
style = Nodes::Scalar::ANY
+ tag = nil
+ str = o
if binary?(o)
str = [o].pack('m').chomp
tag = '!binary' # FIXME: change to below when syck is removed
#tag = 'tag:yaml.org,2002:binary'
style = Nodes::Scalar::LITERAL
+ elsif o =~ /\n/
+ quote = true
+ style = Nodes::Scalar::LITERAL
else
- str = o
- tag = nil
quote = !(String === @ss.tokenize(o))
plain = !quote
end