fix extension matching?

This commit is contained in:
Ward Wouts 2003-04-18 21:06:51 +00:00
parent 64c5370a94
commit 45257627f3

View file

@ -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")
@ -326,20 +329,20 @@ def check_ext(group, filename, mode)
case mode
when "s"
print " sould have extension: #{@config[group]["-S"]}\n";
if ( filename =~ /\.(#{@config[group]["-S"]})$/ )
if ( @config[group].has_key?("-S") && filename =~ /\.(#{@config[group]["-S"]})$/ )
print " extension matches\n"
else
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 " 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"
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