diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-06 03:20:51 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-06 03:20:51 +0000 |
commit | 7c1cd66dd8fe1e7a7553de0442655f1d2584dfd5 (patch) | |
tree | 61a90685b37aff6938b8ccbdf990d4e7345df224 /test | |
parent | f01eb4d0db1cf3cd624358d579070b838a5c1881 (diff) | |
download | ruby-7c1cd66dd8fe1e7a7553de0442655f1d2584dfd5.tar.gz ruby-7c1cd66dd8fe1e7a7553de0442655f1d2584dfd5.tar.xz ruby-7c1cd66dd8fe1e7a7553de0442655f1d2584dfd5.zip |
* enc/trans/escape.trans (escape_html_attr_init): new function.
(fun_so_escape_html_attr): new function.
(escape_html_attr_finish): new function.
(rb_escape_html_attr): use them to quote the converted result.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_econv.rb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index c458371ad..49ba2ae9d 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -727,14 +727,30 @@ class TestEncodingConverter < Test::Unit::TestCase assert_equal("&", ec.convert("&")) end - def test_html_escape + def test_html_escape_text ec = Encoding::Converter.new("", "amp-escaped") assert_equal('&<>"', ec.convert("&<>\"")) + assert_equal('', ec.finish) ec = Encoding::Converter.new("", "html-text-escaped") assert_equal('&<>"', ec.convert("&<>\"")) + assert_equal('', ec.finish) + end + + def test_html_escape_attr + ec = Encoding::Converter.new("", "html-attr-escaped") + assert_equal('""', ec.finish) + + ec = Encoding::Converter.new("", "html-attr-escaped") + assert_equal('', ec.convert("")) + assert_equal('""', ec.finish) + + ec = Encoding::Converter.new("", "html-attr-escaped") + assert_equal('""', ec.convert('"')) + assert_equal('"', ec.finish) ec = Encoding::Converter.new("", "html-attr-escaped") - assert_equal('&<>"', ec.convert("&<>\"")) + assert_equal('"&<>"', ec.convert("&<>\"")) + assert_equal('"', ec.finish) end end |