From 45257627f38a71b0bb453b5a9ce854f6fce848c0 Mon Sep 17 00:00:00 2001 From: Ward Wouts Date: Fri, 18 Apr 2003 21:06:51 +0000 Subject: [PATCH] fix extension matching? --- trunk/ripnews/ripnews.rb | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/trunk/ripnews/ripnews.rb b/trunk/ripnews/ripnews.rb index ed209ce..fb2ff38 100755 --- a/trunk/ripnews/ripnews.rb +++ b/trunk/ripnews/ripnews.rb @@ -1,6 +1,6 @@ #!/usr/local/bin/ruby -w -# $Dwarf: ripnews.rb,v 1.39 2003/03/20 21:53:51 ward Exp $ +# $Dwarf: ripnews.rb,v 1.40 2003/03/21 12:51:21 ward Exp $ # $Source$ require 'date' @@ -246,10 +246,12 @@ def get_multi(subj, group) if @articles.is_uuencoded(body) mode, filename, body = @articles.uudecode(body) return false unless check_ext(group, filename, "m") + print " should have a match here else something's wrong\n" return mode, filename, body elsif @articles.is_yencoded(body) mode, filename, body = @articles.ydecode(body) return false unless check_ext(group, filename, "m") + print " should have a match here else something's wrong\n" return mode, filename, body end print " Unknown encoding (not UU, not yEnc), skipping...\n" @@ -269,6 +271,7 @@ def get_multi(subj, group) end # in plaats van hier return false unless check_ext(group, filename, "m") + print " should have a match here else something's wrong\n" body = fileout.path bodybase = body.sub(/\/[^\/]*$/, "") File.rename(body, "#{bodybase}/ripnewsdecode") @@ -322,24 +325,24 @@ def output_data(subject, mode, filename="", body="") end def check_ext(group, filename, mode) - print "filename: #{filename}\n"; + print " filename: #{filename}\n"; case mode when "s" - print "sould have extension: #{@config[group]["-S"]}\n"; - if ( filename =~ /\.(#{@config[group]["-S"]})$/ ) - print "extension matches\n" + print " sould have extension: #{@config[group]["-S"]}\n"; + if ( @config[group].has_key?("-S") && filename =~ /\.(#{@config[group]["-S"]})$/ ) + print " extension matches\n" else - print "extension doesn't match\n" + print " extension doesn't match\n" end - return @config.has_key?("-S") ? filename =~ /\.(#{@config[group]["-S"]})$/ : true + return @config[group].has_key?("-S") ? ( filename =~ /\.(#{@config[group]["-S"]})$/ ) : true when "m" - if ( filename =~ /\.(#{@config[group]["-M"]})$/ ) - print "extension matches\n" + print " sould have extension: #{@config[group]["-M"]}\n"; + if ( @config[group].has_key?("-S") && filename =~ /\.(#{@config[group]["-M"]})$/ ) + print " extension matches\n" else - print "extension doesn't match\n" + print " extension doesn't match\n" end - print "sould have extension: #{@config[group]["-M"]}\n"; - return @config.has_key?("-M") ? filename =~ /\.(#{@config[group]["-M"]})$/ : true + return @config[group].has_key?("-M") ? ( filename =~ /\.(#{@config[group]["-M"]})$/ ) : true else print "Illegal mode \"#{mode}\" in check_ext\n" exit