summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-06 05:47:30 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-06 05:47:30 +0000
commit1724a119b9a25744b55bffc33a50aef8bdbfe3b1 (patch)
tree648d2c29f5f8c76a53f0b8faede88825cd786551 /test
parent1f311505e6c8c5d42fe074e3af5452ef7f87ec01 (diff)
downloadruby-1724a119b9a25744b55bffc33a50aef8bdbfe3b1.tar.gz
ruby-1724a119b9a25744b55bffc33a50aef8bdbfe3b1.tar.xz
ruby-1724a119b9a25744b55bffc33a50aef8bdbfe3b1.zip
* include/ruby/encoding.h (ECONV_HTML_TEXT_ENCODER): new constant.
(ECONV_HTML_ATTR_ENCODER): ditto. * transcode.c (rb_econv_open): check ECONV_HTML_TEXT_ENCODER and ECONV_HTML_ATTR_ENCODER. (Init_transcode): Encoding::Converter::HTML_TEXT_ENCODER and Encoding::Converter::HTML_ATTR_ENCODER defined. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_econv.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb
index 4e4608c1a..6966ff4e8 100644
--- a/test/ruby/test_econv.rb
+++ b/test/ruby/test_econv.rb
@@ -754,4 +754,18 @@ class TestEncodingConverter < Test::Unit::TestCase
assert_equal('"&amp;&lt;&gt;&quot;', ec.convert("&<>\""))
assert_equal('"', ec.finish)
end
+
+ def test_html_escape_with_charref
+ ec = Encoding::Converter.new("utf-8", "euc-jp", Encoding::Converter::HTML_TEXT_ENCODER|Encoding::Converter::UNDEF_HEX_CHARREF)
+ assert_equal('&lt;&#x2665;&gt;&amp;"&#x2661;"', ec.convert("<\u2665>&\"\u2661\""))
+ assert_equal('', ec.finish)
+
+ ec = Encoding::Converter.new("utf-8", "euc-jp", Encoding::Converter::HTML_ATTR_ENCODER|Encoding::Converter::UNDEF_HEX_CHARREF)
+ assert_equal('"&lt;&#x2665;&gt;&amp;&quot;&#x2661;&quot;', ec.convert("<\u2665>&\"\u2661\""))
+ assert_equal('"', ec.finish)
+
+ ec = Encoding::Converter.new("utf-8", "iso-2022-jp", Encoding::Converter::HTML_TEXT_ENCODER)
+ assert_equal("&amp;\e$B$&\e(B&amp;".force_encoding("iso-2022-jp"), ec.convert("&\u3046&"))
+ assert_equal('', ec.finish)
+ end
end