From 091171a28654801c533166d1819ec7e1705a53ac Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 6 Sep 2008 03:20:51 +0000 Subject: * 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@19173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_econv.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index c458371ad4..49ba2ae9d3 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 -- cgit v1.2.3