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

ruby-changes:36224

From: nobu <ko1@a...>
Date: Thu, 6 Nov 2014 23:55:30 +0900 (JST)
Subject: [ruby-changes:36224] nobu:r48305 (trunk): string.c: no exception in QUOTE

nobu	2014-11-06 23:55:20 +0900 (Thu, 06 Nov 2014)

  New Revision: 48305

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

  Log:
    string.c: no exception in QUOTE
    
    * string.c (sym_printable): QUOTE() should not raise an exception
      even on invalid byte sequence.

  Modified files:
    trunk/ChangeLog
    trunk/string.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48304)
+++ ChangeLog	(revision 48305)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Nov  6 23:55:18 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (sym_printable): QUOTE() should not raise an exception
+	  even on invalid byte sequence.
+
 Thu Nov  6 21:44:36 2014  Tanaka Akira  <akr@f...>
 
 	* test/test_unicode_normalize.rb: Rename TestNormalize to
Index: string.c
===================================================================
--- string.c	(revision 48304)
+++ string.c	(revision 48305)
@@ -8497,8 +8497,11 @@ sym_printable(const char *s, const char https://github.com/ruby/ruby/blob/trunk/string.c#L8497
 {
     while (s < send) {
 	int n;
-	int c = rb_enc_codepoint_len(s, send, &n, enc);
+	int c = rb_enc_precise_mbclen(s, send, enc);
 
+	if (!MBCLEN_CHARFOUND_P(c)) return FALSE;
+	n = MBCLEN_CHARFOUND_LEN(c);
+	c = rb_enc_mbc_to_codepoint(s, send, enc);
 	if (!rb_enc_isprint(c, enc)) return FALSE;
 	s += n;
     }

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

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