Sha256: fbc2170313bc924a7378a1affa1a379b570098bab8d1443756d8ff49c747c411

Contents?: true

Size: 1.21 KB

Versions: 38

Compression:

Stored size: 1.21 KB

Contents

#
# default.rb: included TDiary::Filter::DefaultFilter class
#
# Copyright (C) 2001-2005, TADA Tadashi <t@tdtds.jp>
# You can redistribute it and/or modify it under GPL2 or any later version.
#

module TDiary
	module Filter
		class DefaultFilter < Filter
			def comment_filter( diary, comment )
				if 'POST' != @cgi.request_method then
					return false
				end
				if comment.name.strip.empty? or comment.body.strip.empty? then
					return false
				end
				idx = 1
				diary.each_comment( -1 ) do |com|
					return false if idx >= @conf.comment_limit_per_day
					return false if comment == com
					idx += 1
				end
				true
			end

			def referer_filter( referer )
				if not referer then
					false
				#elsif /[\x00-\x20\x7f-\xff]/ =~ referer then
				#	false
				elsif @conf.bot =~ @cgi.user_agent
					false
				elsif %r|^https?://|i =~ referer
					ref = CGI::unescape( referer.sub( /#.*$/, '' ).sub( /\?\d{8}$/, '' ) ).force_encoding('ASCII-8BIT')
					@conf.no_referer.each do |noref|
						return false if /#{noref.dup.force_encoding('ASCII-8BIT')}/i =~ ref
					end
					true
				else
					false
				end
			end
		end
	end
end

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:

Version data entries

38 entries across 28 versions & 1 rubygems

Version Path
tdiary-5.3.0 lib/tdiary/filter/default.rb
tdiary-5.2.4 lib/tdiary/filter/default.rb
tdiary-5.2.3 lib/tdiary/filter/default.rb
tdiary-5.2.2 lib/tdiary/filter/default.rb
tdiary-5.2.1 lib/tdiary/filter/default.rb
tdiary-5.2.0 lib/tdiary/filter/default.rb
tdiary-5.1.7 lib/tdiary/filter/default.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/lib/tdiary/filter/default.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/lib/tdiary/filter/default.rb
tdiary-5.1.6 lib/tdiary/filter/default.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/lib/tdiary/filter/default.rb
tdiary-5.1.5 lib/tdiary/filter/default.rb
tdiary-5.1.4 lib/tdiary/filter/default.rb
tdiary-5.1.3 lib/tdiary/filter/default.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/tdiary-5.0.14/lib/tdiary/filter/default.rb
tdiary-5.1.2 lib/tdiary/filter/default.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/tdiary-5.0.14/lib/tdiary/filter/default.rb
tdiary-5.1.1 lib/tdiary/filter/default.rb
tdiary-5.1.0 lib/tdiary/filter/default.rb
tdiary-5.0.14 lib/tdiary/filter/default.rb