Sha256: 92871cad191f9b72b3b798366241f8e8a77ca81399da0520e16acab319dbfb80

Contents?: true

Size: 755 Bytes

Versions: 52

Compression:

Stored size: 755 Bytes

Contents

#
# spamlookup.rb: included TDiary::Filter::SpamlookupFilter class
#

require 'resolv'
require 'uri'

module TDiary
  module Filter
    class SpamlookupFilter < Filter
      def black_domain?( domain )
        begin
          Resolv.getaddress( "#{domain}.rbl.bulkfeeds.jp" )
          return true
        rescue
        end
        false
      end

      def black_url?( body )
        URI.extract( body, %w[http] ) do |url|
          domain = URI.parse( url ).host.sub( /\.$/, '' )
          return true if black_domain?( domain )
        end
        false
      end

      def comment_filter( diary, comment )
        !black_url?( comment.body )
      end

      def referer_filter( referer )
        !black_url?( referer )
      end
    end
  end
end

Version data entries

52 entries across 46 versions & 2 rubygems

Version Path
tdiary-contrib-5.3.0 filter/spamlookup.rb
tdiary-contrib-5.2.4 filter/spamlookup.rb
tdiary-contrib-5.2.3 filter/spamlookup.rb
tdiary-contrib-5.2.2 filter/spamlookup.rb
tdiary-contrib-5.2.1 filter/spamlookup.rb
tdiary-contrib-5.2.0 filter/spamlookup.rb
tdiary-contrib-5.1.7 filter/spamlookup.rb
tdiary-contrib-5.1.6 filter/spamlookup.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-contrib-5.1.4/filter/spamlookup.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/bundler/gems/tdiary-contrib-d1e41204db13/filter/spamlookup.rb
tdiary-contrib-5.1.5 filter/spamlookup.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-contrib-5.1.4/filter/spamlookup.rb
tdiary-contrib-5.1.4 filter/spamlookup.rb
tdiary-contrib-5.1.3 filter/spamlookup.rb
tdiary-contrib-5.1.2 filter/spamlookup.rb
tdiary-contrib-5.1.1 filter/spamlookup.rb
tdiary-contrib-5.1.0 filter/spamlookup.rb
tdiary-contrib-5.0.13 filter/spamlookup.rb
tdiary-contrib-5.0.12 filter/spamlookup.rb
tdiary-contrib-5.0.11 filter/spamlookup.rb