[前][次][番号順一覧][スレッド一覧]

ruby-changes:23195

From: tenderlove <ko1@a...>
Date: Sat, 7 Apr 2012 02:09:14 +0900 (JST)
Subject: [ruby-changes:23195] tenderlove:r35245 (trunk): * ext/psych/parser.c: fall back to any encoding if the external

tenderlove	2012-04-07 02:09:03 +0900 (Sat, 07 Apr 2012)

  New Revision: 35245

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35245

  Log:
    * 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

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/parser.c
    trunk/test/psych/test_encoding.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35244)
+++ ChangeLog	(revision 35245)
@@ -1,3 +1,9 @@
+Sat Apr  7 02:07:00 2012  Aaron Patterson <aaron@t...>
+
+	* 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 Apr  6 16:24:24 2012  Martin Duerst  <duerst@i...>
 
 	* struct.c (documentation for rb_struct_members_m):
Index: ext/psych/parser.c
===================================================================
--- ext/psych/parser.c	(revision 35244)
+++ ext/psych/parser.c	(revision 35245)
@@ -146,10 +146,11 @@
 	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
Index: test/psych/test_encoding.rb
===================================================================
--- test/psych/test_encoding.rb	(revision 35244)
+++ test/psych/test_encoding.rb	(revision 35245)
@@ -57,7 +57,7 @@
       # 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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]