summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-04-06 10:09:47 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2012-04-06 10:09:47 -0700
commit62476ce4478c791da949917a580dae51dc600dd3 (patch)
tree143632a185dc74d1fe392f6011a3871fc13ac00b
parentf0040f683c2de6d2674ad573b7dbd0c22386bc7e (diff)
downloadpsych-62476ce4478c791da949917a580dae51dc600dd3.tar.gz
* ext/psych/parser.c: fall back to any encoding if the external
encoding is wrong. [ruby-core:44163] * test/psych/test_encoding.rb: fix test
-rw-r--r--CHANGELOG.rdoc6
-rw-r--r--ext/psych/parser.c7
-rw-r--r--test/psych/test_encoding.rb2
3 files changed, 11 insertions, 4 deletions
diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc
index 1962785..c48b7aa 100644
--- a/CHANGELOG.rdoc
+++ b/CHANGELOG.rdoc
@@ -1,3 +1,9 @@
+Sat Apr 7 02:07:00 2012 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * ext/psych/parser.c: fall back to any encoding if the external
+ encoding is wrong. [ruby-core:44163]
+ * test/psych/test_encoding.rb: fix test
+
Fri Mar 9 06:29:22 2012 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych.rb (load, parse): stop parsing or loading after
diff --git a/ext/psych/parser.c b/ext/psych/parser.c
index 9808c6b..6f4c456 100644
--- a/ext/psych/parser.c
+++ b/ext/psych/parser.c
@@ -146,10 +146,11 @@ static VALUE transcode_io(VALUE src, int * parser_encoding)
return src;
}
- rb_raise(rb_eArgError, "YAML file must be UTF-8, UTF-16LE, or UTF-16BE, not %s",
- rb_enc_name(rb_enc_from_index(io_external_enc_index)));
+ /* If the external encoding is something we don't know how to handle,
+ * fall back to YAML_ANY_ENCODING. */
+ *parser_encoding = YAML_ANY_ENCODING;
- return Qnil;
+ return src;
}
#endif
diff --git a/test/psych/test_encoding.rb b/test/psych/test_encoding.rb
index 8efb676..1abee0d 100644
--- a/test/psych/test_encoding.rb
+++ b/test/psych/test_encoding.rb
@@ -57,7 +57,7 @@ module Psych
# If the external encoding isn't utf8, utf16le, or utf16be, we cannot
# process the file.
File.open(t.path, 'r', :encoding => 'SHIFT_JIS') do |f|
- assert_raises ArgumentError do
+ assert_raises Psych::SyntaxError do
Psych.load(f)
end
end