<commit_before>require 'active_support/core_ext/class/attribute'
require 'active_support/deprecation'
require 'action_view/helpers/sanitize_helper/permit_scrubber'
require 'loofah'

module ActionView

  class FullSanitizer
    def sanitize(html, options = {})
      Loofah.fragment(html).text
    end
  end

  class LinkSanitizer
    def initialize
      @strip_tags = %w(a href)
      @link_scrubber = Loofah::Scrubber.new do |node|
        if @strip_tags.include?(node.name)
          node.before node.children
          node.remove
        else
          Loofah::HTML5::Scrub.scrub_attributes(node)
        end
      end
    end

    def sanitize(html, options = {})
      Loofah.scrub_fragment(html, @link_scrubber).to_s
    end
  end

  class WhiteListSanitizer

    def initialize
      @permit_scrubber = PermitScrubber.new
    end
<commit_msg>Added guard clauses to FullSanitizer.<commit_after>require 'active_support/core_ext/class/attribute'
require 'active_support/deprecation'
require 'action_view/helpers/sanitize_helper/permit_scrubber'
require 'loofah'

module ActionView

  class FullSanitizer
    def sanitize(html, options = {})
      if html
        return html if html.empty?
        Loofah.fragment(html).text
      else
        nil
      end
    end
  end

  class LinkSanitizer
    def initialize
      @strip_tags = %w(a href)
      @link_scrubber = Loofah::Scrubber.new do |node|
        if @strip_tags.include?(node.name)
          node.before node.children
          node.remove
        else
          Loofah::HTML5::Scrub.scrub_attributes(node)
        end
      end
    end

    def sanitize(html, options = {})
      Loofah.scrub_fragment(html, @link_scrubber).to_s
    end
  end

  class WhiteListSanitizer

    def initialize
      @permit_scrubber = PermitScrubber.new
    end

{'fraction_non_alphanumeric': 0.08011049723756906, 'fraction_numerical': 0.0011049723756906078, 'mean_word_length': 2.7263374485596708, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4229573', 'n_tokens_mistral': 597, 'n_tokens_neox': 595, 'n_words': 119}