Skip to content

Commit

Permalink
merge revision(s) 25515:
Browse files Browse the repository at this point in the history
	* string.c (rb_str_inspect): get rid of adding garbage to shor
	  UTF-8 string.  [ruby-dev:39550]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@26078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
shyouhei committed Dec 13, 2009
1 parent cf62471 commit 6de1532
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
Mon Dec 14 00:42:55 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>

* string.c (rb_str_inspect): get rid of adding garbage to shor
UTF-8 string. [ruby-dev:39550]

Sun Dec 13 23:54:22 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>

* marshal.c (marshal_load): should set taintness. [ruby-dev:39723]
Expand Down
4 changes: 2 additions & 2 deletions string.c
Expand Up @@ -2641,8 +2641,8 @@ rb_str_inspect(str)
p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len;
while (p < pend) {
char c = *p++;
if (ismbchar(c) && p < pend) {
int len = mbclen(c);
int len;
if (ismbchar(c) && p + (len = mbclen(c)) <= pend) {
rb_str_buf_cat(result, p - 1, len);
p += len - 1;
}
Expand Down
13 changes: 13 additions & 0 deletions test/ruby/test_string.rb
Expand Up @@ -16,4 +16,17 @@ def test_sum
check_sum("xyz", bits)
}
end

def test_inspect
original_kcode = $KCODE

$KCODE = 'n'
assert_equal('"\343\201\202"', "\xe3\x81\x82".inspect)

$KCODE = 'u'
assert_equal('"\\343\\201\\202"', "\xe3\x81\x82".inspect)
assert_no_match(/\0/, "\xe3\x81".inspect, '[ruby-dev:39550]')
ensure
$KCODE = original_kcode
end
end
2 changes: 1 addition & 1 deletion version.h
Expand Up @@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2009-12-14"
#define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20091214
#define RUBY_PATCHLEVEL 226
#define RUBY_PATCHLEVEL 227

#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
Expand Down

0 comments on commit 6de1532

Please sign in to comment.