<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/white_lister.rb</filename>
    </added>
    <added>
      <filename>test/white_list_helper_test.rb</filename>
    </added>
    <added>
      <filename>test/white_lister_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,2 +1,3 @@
+require 'white_lister'
 require 'white_list_helper'
 ActionView::Base.send :include, WhiteListHelper
\ No newline at end of file</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,6 @@
 module WhiteListHelper
-  @@protocol_attributes = Set.new %w(src href)
-  @@protocol_separator  = /:|(&amp;#0*58)|(&amp;#x70)|(%|&amp;#37;)3A/
-  mattr_reader :protocol_attributes, :protocol_separator
-
-  def self.contains_bad_protocols?(white_listed_protocols, value)
-    value =~ protocol_separator &amp;&amp; !white_listed_protocols.include?(value.split(protocol_separator).first)
-  end
+  
+  @@white_lister ||= WhiteLister.new
 
   klass = class &lt;&lt; self; self; end
   klass_methods = []
@@ -13,8 +8,8 @@ module WhiteListHelper
   [:bad_tags, :tags, :attributes, :protocols].each do |attr|
     # Add class methods to the module itself
     klass_methods &lt;&lt; &lt;&lt;-EOS
-      def #{attr}=(value) @@#{attr} = Set.new(value) end
-      def #{attr}() @@#{attr} end
+      def #{attr}=(value) @@white_lister.instance_variable_set(:@#{attr}, Set.new(value)) end
+      def #{attr}() @@white_lister.instance_variable_get(:@#{attr}) end
     EOS
     
     # prefix the instance methods with white_listed_*
@@ -51,47 +46,13 @@ module WhiteListHelper
   # 
   #   &lt;%= white_list(@article.body) { |node, bad| white_listed_bad_tags.include?(bad) ? nil : node.to_s.gsub(/&lt;/, '&amp;lt;') } %&gt;
   #
-  def white_list(html, options = {}, &amp;block)
-    return html if html.blank? || !html.include?('&lt;')
-    attrs   = Set.new(options[:attributes]).merge(white_listed_attributes)
-    tags    = Set.new(options[:tags]      ).merge(white_listed_tags)
-    block ||= lambda { |node, bad| white_listed_bad_tags.include?(bad) ? nil : node.to_s.gsub(/&lt;/, '&amp;lt;') }
-    returning [] do |new_text|
-      tokenizer = HTML::Tokenizer.new(html)
-      bad       = nil
-      while token = tokenizer.next
-        node = HTML::Node.parse(nil, 0, 0, token, false)
-        new_text &lt;&lt; case node
-          when HTML::Tag
-            node.attributes.keys.each do |attr_name|
-              value = node.attributes[attr_name].to_s
-              if !attrs.include?(attr_name) || (protocol_attributes.include?(attr_name) &amp;&amp; contains_bad_protocols?(value))
-                node.attributes.delete(attr_name)
-              else
-                node.attributes[attr_name] = CGI::escapeHTML(value)
-              end
-            end if node.attributes
-            if tags.include?(node.name)
-              bad = nil
-              node
-            else
-              bad = node.name
-              block.call node, bad
-            end
-          else
-            block.call node, bad
-        end
-      end
-    end.join
+  def white_list(*args, &amp;blk)
+    @@white_lister.white_list(*args, &amp;blk)
   end
   
   protected
+  
     def contains_bad_protocols?(value)
-      WhiteListHelper.contains_bad_protocols?(white_listed_protocols, value)
+      @@white_lister.send(:contains_bad_protocols?, value)
     end
-end
-
-WhiteListHelper.bad_tags   = %w(script)
-WhiteListHelper.tags       = %w(strong em b i p code pre tt output samp kbd var sub sup dfn cite big small address hr br div span h1 h2 h3 h4 h5 h6 ul ol li dt dd abbr acronym a img blockquote del ins fieldset legend)
-WhiteListHelper.attributes = %w(href src width height alt cite datetime title class)
-WhiteListHelper.protocols  = %w(ed2k ftp http https irc mailto news gopher nntp telnet webcal xmpp callto feed)
\ No newline at end of file
+end
\ No newline at end of file</diff>
      <filename>lib/white_list_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>test/white_list_test.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>b607ba57dea7aa93e454eed35cc590179ed5ab9a</id>
    </parent>
  </parents>
  <author>
    <name>Dima Sabanin</name>
    <email>sdmitry@gmail.com</email>
  </author>
  <url>http://github.com/railsmonk/white_list_objectified/commit/db4d6591d02298bba43842539bf98eb7150c7351</url>
  <id>db4d6591d02298bba43842539bf98eb7150c7351</id>
  <committed-date>2008-09-24T09:00:37-07:00</committed-date>
  <authored-date>2008-09-24T09:00:12-07:00</authored-date>
  <message>Objectified version of the plugin. Moved all white listing related code from helper module into separate class WhiteLister. Left previous API in place, so that old test files pass unchanged, this will ensure backward compatibility to some extent. Also, copied and rewritten old tests to cover WhiteLister class.</message>
  <tree>d83ac65cb43113299fc1c1b9a19366b5b6655a8f</tree>
  <committer>
    <name>Dima Sabanin</name>
    <email>sdmitry@gmail.com</email>
  </committer>
</commit>
