Forum: Ruby quirks with \0 in double quotes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
47b1910084592eb77a032bc7d8d1a84e?d=identicon&s=25 Joel VanderWerf (Guest)
on 2006-03-17 06:24
(Received via mailing list)
Are these bugs? This is ruby-1.8.4. The YAML spec seems to say "\0" is
legit.

------------------------------------
require 'yaml'

m = YAML.load(<<END)
  a: 4
  b: "\0\0"
  c: 5
END

p m
puts

m = YAML.load(<<END)
  a: 4
#  b: "\0\0\0\0\0\0\0\0\0\0\0\0\0"
  b: 6
  c: 5
END

p m
puts

begin
m = YAML.load(<<END)
  a: 4
  b: "\0"
  c: 5
END
rescue => ex
  p ex
  puts ex.backtrace
end


__END__

Output:

{"a"=>4, "b"=>""}

{"a"=>4}

#<ArgumentError: syntax error on line 3, col 1: `'>
/usr/local/lib/ruby/1.8/yaml.rb:133:in `load'
/usr/local/lib/ruby/1.8/yaml.rb:133:in `load'
-:23
This topic is locked and can not be replied to.