mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/syck/emitter.c (syck_scan_scalar): prevent indicators from
appearing alone or at the end of plain scalars. [ruby-core:5826] * ext/syck/emitter.c (syck_emit_scalar): treat typed scalar nodes as complex keys. * lib/syck.h: version 0.60. * lib/yaml/basenode.rb (YAML::BaseNode#at): transform keys during key searches. * ext/syck/rubyext.c: loading of binary-typed nodes. prevent emission of plain strings that look like symbols, but which aren't. * ext/syck/emitter.c (syck_emit): passing an int* value to the long* parameter causes unaligned access on LP64 systems. [ruby-dev:27161] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
34b3f481dc
commit
d578f9d32e
10 changed files with 395 additions and 356 deletions
|
|
@ -137,6 +137,7 @@ end
|
|||
|
||||
class String
|
||||
yaml_as "tag:ruby.yaml.org,2002:string"
|
||||
yaml_as "tag:yaml.org,2002:binary"
|
||||
yaml_as "tag:yaml.org,2002:str"
|
||||
def is_complex_yaml?
|
||||
to_yaml_style or not to_yaml_properties.empty? or self =~ /\n.+/
|
||||
|
|
@ -145,6 +146,7 @@ class String
|
|||
( self.count( "^ -~", "^\r\n" ) / self.size > 0.3 || self.count( "\x00" ) > 0 ) unless empty?
|
||||
end
|
||||
def String.yaml_new( klass, tag, val )
|
||||
val = val.unpack("m")[0] if tag == "tag:yaml.org,2002:binary"
|
||||
val = { 'str' => val } if String === val
|
||||
if Hash === val
|
||||
s = klass.allocate
|
||||
|
|
@ -163,7 +165,7 @@ class String
|
|||
if is_binary_data?
|
||||
out.scalar( "tag:yaml.org,2002:binary", [self].pack("m"), :literal )
|
||||
elsif to_yaml_properties.empty?
|
||||
out.scalar( taguri, self, to_yaml_style )
|
||||
out.scalar( taguri, self, self =~ /^:/ ? :quote2 : to_yaml_style )
|
||||
else
|
||||
out.map( taguri, to_yaml_style ) do |map|
|
||||
map.add( 'str', "#{self}" )
|
||||
|
|
@ -179,7 +181,6 @@ end
|
|||
class Symbol
|
||||
yaml_as "tag:ruby.yaml.org,2002:symbol"
|
||||
yaml_as "tag:ruby.yaml.org,2002:sym"
|
||||
# yaml_implicit /^:/, :yaml_new
|
||||
def Symbol.yaml_new( klass, tag, val )
|
||||
if String === val
|
||||
val.intern
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue