<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -69,7 +69,7 @@ module HTML
 
     # Specifies a Set of 'bad' tags that the #sanitize helper will remove completely, as opposed
     # to just escaping harmless tags like &amp;lt;font&amp;gt;
-    self.bad_tags               = Set.new(%w(script))
+    self.bad_tags               = Set.new(%w(script form input plaintext))
     
     # Specifies the default Set of tags that the #sanitize helper will allow unscathed.
     self.allowed_tags           = Set.new(%w(strong em b i p code pre tt samp kbd var sub 
@@ -146,9 +146,9 @@ module HTML
           
           process_attributes_for node, options
 
-          options[:tags].include?(node.name) ? node : nil
+          options[:tags].include?(node.name) ? node : bad_tags.include?(node.name) ? nil : node.to_s.gsub(/&lt;/, &quot;&amp;lt;&quot;)
         else
-          bad_tags.include?(options[:parent].first) ? nil : node.to_s.gsub(/&lt;/, &quot;&amp;lt;&quot;)
+          bad_tags.include?(options[:parent].first) ? nil : node.to_s
       end
     end
     </diff>
      <filename>actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -65,7 +65,7 @@ class SanitizerTest &lt; Test::Unit::TestCase
 
   HTML::WhiteListSanitizer.allowed_tags.each do |tag_name|
     define_method &quot;test_should_allow_#{tag_name}_tag&quot; do
-      assert_sanitized &quot;start &lt;#{tag_name} title=\&quot;1\&quot; onclick=\&quot;foo\&quot;&gt;foo &lt;bad&gt;bar&lt;/bad&gt; baz&lt;/#{tag_name}&gt; end&quot;, %(start &lt;#{tag_name} title=&quot;1&quot;&gt;foo bar baz&lt;/#{tag_name}&gt; end)
+      assert_sanitized &quot;start &lt;#{tag_name} title=\&quot;1\&quot; onclick=\&quot;foo\&quot;&gt;foo &lt;bad&gt;bar&lt;/bad&gt; baz&lt;/#{tag_name}&gt; end&quot;, %(start &lt;#{tag_name} title=&quot;1&quot;&gt;foo &amp;lt;bad&gt;bar&amp;lt;/bad&gt; baz&lt;/#{tag_name}&gt; end)
     end
   end
 
@@ -102,7 +102,7 @@ class SanitizerTest &lt; Test::Unit::TestCase
   def test_should_allow_only_custom_tags
     text = &quot;&lt;u&gt;foo&lt;/u&gt; with &lt;i&gt;bar&lt;/i&gt;&quot;
     sanitizer = HTML::WhiteListSanitizer.new
-    assert_equal(&quot;&lt;u&gt;foo&lt;/u&gt; with bar&quot;, sanitizer.sanitize(text, :tags =&gt; %w(u)))
+    assert_equal(&quot;&lt;u&gt;foo&lt;/u&gt; with &amp;lt;i&gt;bar&amp;lt;/i&gt;&quot;, sanitizer.sanitize(text, :tags =&gt; %w(u)))
   end
 
   def test_should_allow_custom_tags_with_attributes
@@ -167,7 +167,7 @@ class SanitizerTest &lt; Test::Unit::TestCase
   end
   
   def test_should_sanitize_tag_broken_up_by_null
-    assert_sanitized %(&lt;SCR\0IPT&gt;alert(\&quot;XSS\&quot;)&lt;/SCR\0IPT&gt;), &quot;alert(\&quot;XSS\&quot;)&quot;
+    assert_sanitized %(&lt;SCR\0IPT&gt;alert(\&quot;XSS\&quot;)&lt;/SCR\0IPT&gt;), &quot;&amp;lt;scr&gt;alert(\&quot;XSS\&quot;)&amp;lt;/scr&gt;&quot;
   end
   
   def test_should_sanitize_invalid_script_tag
@@ -175,8 +175,8 @@ class SanitizerTest &lt; Test::Unit::TestCase
   end
   
   def test_should_sanitize_script_tag_with_multiple_open_brackets
-    assert_sanitized %(&lt;&lt;SCRIPT&gt;alert(&quot;XSS&quot;);//&lt;&lt;/SCRIPT&gt;), &quot;&amp;lt;&quot;
-    assert_sanitized %(&lt;iframe src=http://ha.ckers.org/scriptlet.html\n&lt;a), %(&amp;lt;a)
+    assert_sanitized %(&lt;&lt;SCRIPT&gt;alert(&quot;XSS&quot;);//&lt;&lt;/SCRIPT&gt;), &quot;&lt;&quot;
+    assert_sanitized %(&lt;&lt;iframe src=http://ha.ckers.org/scriptlet.html\n&lt;a), %(&lt;&amp;lt;iframe src=\&quot;http:\&quot; /&gt;&lt;a)
   end
   
   def test_should_sanitize_unclosed_script
@@ -243,6 +243,11 @@ class SanitizerTest &lt; Test::Unit::TestCase
   def test_should_sanitize_img_vbscript
      assert_sanitized %(&lt;img src='vbscript:msgbox(&quot;XSS&quot;)' /&gt;), '&lt;img /&gt;'
   end
+  
+  def test_should_not_remove_unknown_tags
+     assert_sanitized %{begin &lt;foo&gt;foobar&lt;/bar&gt; end}, 'begin &amp;lt;foo&gt;foobar&amp;lt;/bar&gt; end'
+  end
+ 
 
 protected
   def assert_sanitized(input, expected = nil)</diff>
      <filename>actionpack/test/controller/html-scanner/sanitizer_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4a98c7b01d2cec55ec58837f637839487b427337</id>
    </parent>
  </parents>
  <author>
    <name>Anton Mostovoy</name>
    <email>anton@mostovoy.net</email>
  </author>
  <url>http://github.com/antonmos/rails/commit/54fa6cd0d6babf00a251584499500e7466273944</url>
  <id>54fa6cd0d6babf00a251584499500e7466273944</id>
  <committed-date>2008-08-27T07:42:08-07:00</committed-date>
  <authored-date>2008-08-27T07:42:08-07:00</authored-date>
  <message>sanitize unknown tags with &amp;lt; instead of deleting
fixes http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/916-whitelistsanitizer-removes-unknown-tags-instead-of-escaping</message>
  <tree>9ee103c9452b87586d92e6eb762f7aab396ed23c</tree>
  <committer>
    <name>Anton Mostovoy</name>
    <email>anton@mostovoy.net</email>
  </committer>
</commit>
