Changeset 6008

Show
Ignore:
Timestamp:
02/02/08 01:25:02 (5 years ago)
Author:
drry
Message:

platform/tdiary/filter/antirefspam.rb
platform/tdiary/plugin/antirefspam.rb: コメント中のファイル名を修正しました。正規表現を変更しました。自信がない部分はコメントに残しました。

Location:
platform/tdiary
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • platform/tdiary/filter/antirefspam.rb

    r5585 r6008  
    11# 
    2 # antirefspamfilter.rb 
     2# antirefspam.rb 
    33# 
    44# Copyright (c) 2004-2005 T.Shimomura <redbug@netlife.gr.jp> 
     
    3636        # str にトップページURLが含まれているかどうか 
    3737        unless @conf.index_page.empty? 
    38           if /\Ahttps?:\/\// =~ @conf.index_page 
     38          if @conf.index_page.index(URI.regexp(%w[http https])) == 0 
    3939            if str.include? @conf.index_page 
    4040              return true 
     
    4848            return true 
    4949          end 
    50            
    51           url = myurl.gsub("/", "\\/").gsub(":", "\\:") 
    52           exp = Regexp.new(url) 
     50 
     51          #url = myurl.gsub("/", "\\/").gsub(":", "\\:") 
     52          #exp = Regexp.new(url) 
     53          exp = Regexp.union(myurl) 
    5354          if exp =~ str 
    5455            return true 
     
    7677        # "信頼できるURL" を1つずつ取り出してrefererと合致するかチェックする 
    7778        conf_trustedurl.each_line do |trusted| 
    78           trusted.sub!(/\r?\n/,'') 
     79          trusted.sub!(/\r?\n|\r/,'') 
    7980          next if trusted =~ /\A(\#|\s*)\z/  # #または空白で始まる行は読み飛ばす 
    80            
     81 
    8182          # まずは "信頼できる URL" が referer に含まれるかどうか 
    8283          if referer.include? trusted 
     
    8485            return true 
    8586          end 
    86            
     87 
    8788          # 含まれなかった場合は "信頼できる URL" を正規表現とみなして再チェック 
    8889          begin 
    89             if referer =~ Regexp.new( trusted.gsub("/", "\\/").gsub(":", "\\:") ) 
     90            #if referer =~ Regexp.new( trusted.gsub("/", "\\/").gsub(":", "\\:") ) 
     91            if referer =~ Regexp.union( trusted ) 
    9092              debug_out("trusted", trusted+" (=~) "+referer) 
    9193              return true 
     
    237239          ngwords = @conf['antirefspam.comment_ngwords'] 
    238240          ngwords.to_s.each_line do |ngword| 
    239             ngword.sub!(/\r?\n/,'') 
     241            ngword.sub!(/\r?\n|\r/,'') 
    240242            if comment.body.downcase.include? ngword.downcase 
    241243              log_spamcomment( comment ) 
  • platform/tdiary/plugin/antirefspam.rb

    r5381 r6008  
    11# 
    2 # antirefspam.rb  
     2# antirefspam.rb 
    33# 
    44# Copyright (c) 2004-2005 T.Shimomura <redbug@netlife.gr.jp>