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

ruby-changes:39935

From: naruse <ko1@a...>
Date: Sun, 4 Oct 2015 15:14:04 +0900 (JST)
Subject: [ruby-changes:39935] naruse:r52016 (trunk): * enc/euc_jp.c (mbc_case_fold): check given string is valid or not,

naruse	2015-10-04 15:13:48 +0900 (Sun, 04 Oct 2015)

  New Revision: 52016

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

  Log:
    * enc/euc_jp.c (mbc_case_fold): check given string is valid or not,
      and if invalid, return 1. [Bug #11486]

  Modified files:
    trunk/ChangeLog
    trunk/enc/euc_jp.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52015)
+++ ChangeLog	(revision 52016)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Oct  4 15:11:48 2015  NARUSE, Yui  <naruse@r...>
+
+	* enc/euc_jp.c (mbc_case_fold): check given string is valid or not,
+	  and if invalid, return 1. [Bug #11486]
+
 Sun Oct  4 10:09:57 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* dir.c (rb_dir_getwd): normalize OS path to UTF-8 on OS X.
Index: enc/euc_jp.c
===================================================================
--- enc/euc_jp.c	(revision 52015)
+++ enc/euc_jp.c	(revision 52016)
@@ -378,11 +378,12 @@ mbc_case_fold(OnigCaseFoldType flag, https://github.com/ruby/ruby/blob/trunk/enc/euc_jp.c#L378
     return 1;
   }
   else {
-    OnigCodePoint code;
     int len;
 
+    len = mbc_enc_len(p, end, enc);
+    if (len <= 0) return 1;
     code = get_lower_case(mbc_to_code(p, end, enc));
-    len = code_to_mbc(code, lower, enc);
+    /* assuming case folding in euc-jp doesn't change length */
     (*pp) += len;
     return len; /* return byte length of converted char to lower */
   }

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

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