<commit_before>require 'action_dispatch/middleware/cookies'
module ActionDispatch
  class DummySerializer
    def self.load(string)
      string
    end
  end
  class Flash
    # Based on definition of FlashHash in Rails 3.0
    class FlashHashKludge < Hash
      def initialize #:nodoc:
        super
        @used = Set.new
      end
    end
  end
  class Cookies
    class SignedCookieJar
      def initialize(parent_jar, secret)
        ensure_secret_secure(secret)
        @parent_jar = parent_jar
        @verifier   = ActiveSupport::MessageVerifier.new(secret)
        @nonloading_verifier = ActiveSupport::MessageVerifier.new(secret, :serializer => DummySerializer)
      end
      def [](name)
        if signed_message = @parent_jar[name]
          begin
            @verifier.verify(signed_message)
          rescue ArgumentError
            string = @nonloading_verifier.verify(signed_message)

            # Swap FlashHash Class
            original_flash_hash_klass = ActionDispatch::Flash::FlashHash
            ActionDispatch::Flash.send :remove_const, :FlashHash
            ActionDispatch::Flash.const_set 'FlashHash', Flash::FlashHashKludge
<commit_msg>Use #alias_method_chain instead of copying function from source<commit_after>require 'action_dispatch/middleware/cookies'
module ActionDispatch
  class DummySerializer
    def self.load(string)
      string
    end
  end
  class Flash
    # Based on definition of FlashHash in Rails 3.0
    class FlashHashKludge < Hash
      def initialize #:nodoc:
        super
        @used = Set.new
      end
    end
  end
  class Cookies
    class SignedCookieJar
      def initialize_with_nonloading_verifier(parent_jar, secret)
        initialize_without_nonloading_verifier(parent_jar, secret)
        @nonloading_verifier = ActiveSupport::MessageVerifier.new(secret, :serializer => DummySerializer)
      end
      alias_method_chain :initialize, :nonloading_verifier
      def [](name)
        if signed_message = @parent_jar[name]
          begin
            @verifier.verify(signed_message)
          rescue ArgumentError
            string = @nonloading_verifier.verify(signed_message)

            # Swap FlashHash Class
            original_flash_hash_klass = ActionDispatch::Flash::FlashHash
            ActionDispatch::Flash.send :remove_const, :FlashHash
            ActionDispatch::Flash.const_set 'FlashHash', Flash::FlashHashKludge

{'fraction_non_alphanumeric': 0.06556016597510374, 'fraction_numerical': 0.0016597510373443983, 'mean_word_length': 2.869983948635634, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3992419', 'n_tokens_mistral': 676, 'n_tokens_neox': 652, 'n_words': 151}