aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/psych/lib/psych.rb4
-rw-r--r--test/psych/test_tainted.rb2
3 files changed, 9 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index d6e2f02da8..6b7c1a8501 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Feb 28 10:28:51 2012 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * ext/psych/lib/psych.rb: default open YAML files with utf8 external
+ encoding. [ruby-core:42967]
+ * test/psych/test_tainted.rb: ditto
+
Mon Feb 27 23:46:09 2012 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (opt_bv_decl): allow newline at the end. [ruby-dev:45292]
diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index 3b7f9a34f2..cb5c4a5cf3 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -156,7 +156,7 @@ module Psych
#
# Raises a Psych::SyntaxError when a YAML syntax error is detected.
def self.parse_file filename
- File.open filename do |f|
+ File.open filename, 'r:bom|utf-8' do |f|
parse f, filename
end
end
@@ -264,7 +264,7 @@ module Psych
# Load the document contained in +filename+. Returns the yaml contained in
# +filename+ as a ruby object
def self.load_file filename
- File.open(filename) { |f| self.load f, filename }
+ File.open(filename, 'r:bom|utf-8') { |f| self.load f, filename }
end
# :stopdoc:
diff --git a/test/psych/test_tainted.rb b/test/psych/test_tainted.rb
index 00d220e825..fdcced4cf3 100644
--- a/test/psych/test_tainted.rb
+++ b/test/psych/test_tainted.rb
@@ -121,7 +121,7 @@ module Psych
t.binmode
t.write string
t.close
- File.open(t.path) { |f|
+ File.open(t.path, 'r:bom|utf-8') { |f|
@parser.parse f
}
t.close(true)