mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Scan the coderange in the given encoding --- ext/-test-/string/enc_str_buf_cat.c | 14 ++++++++++++++ string.c | 32 ++++++++++++++++++++++--------- test/-ext-/string/test_enc_str_buf_cat.rb | 9 +++++++++ 3 files changed, 46 insertions(+), 9 deletions(-) Work around issue transcoding issue with non-ASCII compatible encodings and xml escaping When using a non-ASCII compatible source and destination encoding and xml escaping (the :xml option to String#encode), the resulting string was broken, as it used the correct non-ASCII compatible encoding, but contained data that was ASCII-compatible instead of compatible with the string's encoding. Work around this issue by detecting the case where both the source and destination encoding are non-ASCII compatible, and transcoding the source string from the non-ASCII compatible encoding to UTF-8. The xml escaping code will correctly handle the UTF-8 source string and the return the correctly encoded and escaped value. Fixes [Bug #12052] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> --- test/ruby/test_transcode.rb | 19 +++++++++++++++++++ transcode.c | 6 ++++++ 2 files changed, 25 insertions(+) =?UTF-8?q?-=20add=20regression=20tests=20for=20U+6E7F=20(?= =?UTF-8?q?=E6=B9=BF)=20in=20ISO-2022-JP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In ISO-2022-JP, the bytes use to code are the same as those for "<>". This adds regression tests to make sure that these bytes, when representing 湿, are NOT escaped with encode("ISO-2022-JP, xml: :text) or similar. These are additional regression tests for #12052. --- test/ruby/test_transcode.rb | 3 +++ 1 file changed, 3 insertions(+) |
||
|---|---|---|
| .. | ||
| -ext- | ||
| base64 | ||
| benchmark | ||
| bigdecimal | ||
| cgi | ||
| coverage | ||
| csv | ||
| date | ||
| dbm | ||
| did_you_mean | ||
| digest | ||
| drb | ||
| dtrace | ||
| erb | ||
| etc | ||
| excludes | ||
| fiber | ||
| fiddle | ||
| fileutils | ||
| fixtures/fake_sorted_set_gem | ||
| gdbm | ||
| io | ||
| irb | ||
| json | ||
| lib | ||
| logger | ||
| matrix | ||
| mkmf | ||
| monitor | ||
| net | ||
| nkf | ||
| objspace | ||
| open-uri | ||
| openssl | ||
| optparse | ||
| ostruct | ||
| pathname | ||
| psych | ||
| racc | ||
| rdoc | ||
| readline | ||
| reline | ||
| resolv | ||
| rinda | ||
| ripper | ||
| ruby | ||
| rubygems | ||
| socket | ||
| stringio | ||
| strscan | ||
| syslog | ||
| uri | ||
| win32ole | ||
| yaml | ||
| zlib | ||
| runner.rb | ||
| test_abbrev.rb | ||
| test_delegate.rb | ||
| test_extlibs.rb | ||
| test_find.rb | ||
| test_forwardable.rb | ||
| test_ipaddr.rb | ||
| test_mutex_m.rb | ||
| test_observer.rb | ||
| test_open3.rb | ||
| test_pp.rb | ||
| test_prettyprint.rb | ||
| test_prime.rb | ||
| test_pstore.rb | ||
| test_pty.rb | ||
| test_rbconfig.rb | ||
| test_securerandom.rb | ||
| test_set.rb | ||
| test_shellwords.rb | ||
| test_singleton.rb | ||
| test_sorted_set.rb | ||
| test_syslog.rb | ||
| test_tempfile.rb | ||
| test_time.rb | ||
| test_timeout.rb | ||
| test_tmpdir.rb | ||
| test_tracer.rb | ||
| test_tsort.rb | ||
| test_unicode_normalize.rb | ||
| test_weakref.rb | ||