YAML modifies strings when it serializes them. What the crap?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby --version | |
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.5.0] | |
$ ruby yaml_bug.rb | |
YAML modifies strings when it serializes them! | |
Original: "1\n \n2" | |
Modified: "1\n\n2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yaml' | |
string = "1\n \n2" | |
modified_string = YAML.load(string.to_yaml) | |
if string == modified_string | |
puts "YAML does not modify strings when it serializes them." | |
else | |
puts "YAML modifies strings when it serializes them!" | |
puts "Original: #{string.inspect}" | |
puts "Modified: #{modified_string.inspect}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment