aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--ext/psych/lib/psych.rb2
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb2
-rw-r--r--ext/psych/psych_emitter.c4
-rw-r--r--test/psych/test_encoding.rb9
5 files changed, 22 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ab373903f5..874b7ea8ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Sep 2 18:49:55 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
+
+ * ext/psych/*: merge psych master(8737e5b). It contains following fixes.
+ https://github.com/tenderlove/psych/pull/242
+ https://github.com/tenderlove/psych/pull/246 [ruby-list:50219]
+ * test/psych/*: ditto.
+
Wed Sep 2 18:04:13 2015 Koichi Sasada <ko1@atdot.net>
* vm_insnhelper.h (GET_PC_COUNT): remove unused macro.
diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index ef8f12a472..1a3cb65ebc 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -223,7 +223,7 @@ require 'psych/class_loader'
module Psych
# The version is Psych you're using
- VERSION = '2.0.14'
+ VERSION = '2.0.15'
# The version of libyaml Psych is using
LIBYAML_VERSION = Psych.libyaml_version.join '.'
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index e13fd774e8..3087a4db1c 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -156,7 +156,7 @@ module Psych
end
def visit_Psych_Omap o
- seq = @emitter.start_sequence(nil, '!omap', false, Nodes::Sequence::BLOCK)
+ seq = @emitter.start_sequence(nil, 'tag:yaml.org,2002:omap', false, Nodes::Sequence::BLOCK)
register(o, seq)
o.each { |k,v| visit_Hash k => v }
diff --git a/ext/psych/psych_emitter.c b/ext/psych/psych_emitter.c
index feffc54ce7..f77d8d7d86 100644
--- a/ext/psych/psych_emitter.c
+++ b/ext/psych/psych_emitter.c
@@ -15,7 +15,11 @@ static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
static int writer(void *ctx, unsigned char *buffer, size_t size)
{
VALUE io = (VALUE)ctx;
+#ifdef HAVE_RUBY_ENCODING_H
+ VALUE str = rb_enc_str_new((const char *)buffer, (long)size, rb_utf8_encoding());
+#else
VALUE str = rb_str_new((const char *)buffer, (long)size);
+#endif
VALUE wrote = rb_funcall(io, id_write, 1, str);
return (int)NUM2INT(wrote);
}
diff --git a/test/psych/test_encoding.rb b/test/psych/test_encoding.rb
index 517cae2069..544337d4c0 100644
--- a/test/psych/test_encoding.rb
+++ b/test/psych/test_encoding.rb
@@ -249,6 +249,15 @@ module Psych
assert_encodings @utf8, @handler.strings
end
+ def test_dump_non_ascii_string_to_file
+ Tempfile.create(['utf8', 'yml'], :encoding => 'UTF-8') do |t|
+ h = {'one' => 'いち'}
+ Psych.dump(h, t)
+ t.close
+ assert_equal h, Psych.load_file(t.path)
+ end
+ end
+
private
def assert_encodings encoding, strings
strings.each do |str|