Actions
Bug #1365
closedString#dump with non-ascii-compatible string provides invalid code
Description
=begin
遠藤です。
アスキー非互換な文字列を String#dump すると eval できない文字列が
得られました。
$ ./ruby -e 'p "\u3042".encode("UTF-16LE").dump'
""B0".force_encoding("UTF-16LE"\x00"
Index: string.c¶
--- string.c (revision 23159)
+++ string.c (working copy)
@@ -4291,7 +4291,7 @@
result = rb_str_new5(str, 0, len);
p = RSTRING_PTR(str); pend = p + RSTRING_LEN(str);
- q = RSTRING_PTR(result); qend = q + len;
-
q = RSTRING_PTR(result); qend = q + len + 1;
*q++ = '"';
while (p < pend) {
Index: test/ruby/test_m17n.rb
===================================================================
--- test/ruby/test_m17n.rb (revision 23159)
+++ test/ruby/test_m17n.rb (working copy)
@@ -241,6 +241,9 @@
u("\xfc"),
"\u3042",
"ascii", -
"\u3042".encode("UTF-16LE"),
-
"\u3042".encode("UTF-16BE"),
].each do |str|
assert_equal(str, eval(str.dump), "[ruby-dev:33142]")
end
--
Yusuke ENDOH [email protected]
=end
Updated by mame (Yusuke Endoh) about 16 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r23160.
=end
Actions
Like0
Like0