this sould fix extension filtering
have yet to test
This commit is contained in:
parent
a1d6be8167
commit
a5990db291
1 changed files with 16 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/local/bin/ruby -w
|
||||
|
||||
# $Dwarf: ripnews.rb,v 1.37 2002/11/05 09:33:41 ward Exp $
|
||||
# $Dwarf: ripnews.rb,v 1.38 2003/03/17 08:42:51 ward Exp $
|
||||
# $Source$
|
||||
|
||||
require 'date'
|
||||
|
|
@ -222,17 +222,17 @@ def check_config
|
|||
}
|
||||
end
|
||||
|
||||
def get_single(subj)
|
||||
def get_single(subj, group)
|
||||
print "Fetching singlepart article: #{subj}\n"
|
||||
body = @articles.get_group_body(subj)
|
||||
if @articles.is_uuencoded(body)
|
||||
mode, filename, body = @articles.uudecode(body)
|
||||
return false unless check_ext(filename, "s")
|
||||
return false unless check_ext(group, filename, "s")
|
||||
return mode, filename, body
|
||||
end
|
||||
if @articles.is_yencoded(body)
|
||||
mode, filename, body = @articles.ydecode(body)
|
||||
return false unless check_ext(filename, "s")
|
||||
return false unless check_ext(group, filename, "s")
|
||||
return mode, filename, body
|
||||
end
|
||||
print " Unknown encoding (not UU, not yEnc), skipping...\n"
|
||||
|
|
@ -245,11 +245,11 @@ def get_multi(subj, group)
|
|||
body = @articles.get_group_body(subj)
|
||||
if @articles.is_uuencoded(body)
|
||||
mode, filename, body = @articles.uudecode(body)
|
||||
return false unless check_ext(filename, "m")
|
||||
return false unless check_ext(group, filename, "m")
|
||||
return mode, filename, body
|
||||
elsif @articles.is_yencoded(body)
|
||||
mode, filename, body = @articles.ydecode(body)
|
||||
return false unless check_ext(filename, "m")
|
||||
return false unless check_ext(group, filename, "m")
|
||||
return mode, filename, body
|
||||
end
|
||||
print " Unknown encoding (not UU, not yEnc), skipping...\n"
|
||||
|
|
@ -259,6 +259,7 @@ def get_multi(subj, group)
|
|||
if @articles.is_uuencoded(body) or @articles.is_yencoded(body)
|
||||
file = Tempfile.new("riptmp", @config[group]["TEMPDIR"])
|
||||
body.collect{|x| file.print "#{x}\n"}
|
||||
# hire moet een extensie check!!!
|
||||
return false unless @articles.get_group_body_rest(subj, file)
|
||||
fileout = Tempfile.new("riptmp", @config[group]["TEMPDIR"])
|
||||
if @articles.is_uuencoded(body)
|
||||
|
|
@ -266,7 +267,8 @@ def get_multi(subj, group)
|
|||
elsif @articles.is_yencoded(body)
|
||||
mode, filename, body = @articles.ydecode(file, fileout)
|
||||
end
|
||||
return false unless check_ext(filename, "m")
|
||||
# in plaats van hier
|
||||
return false unless check_ext(group, filename, "m")
|
||||
body = fileout.path
|
||||
bodybase = body.sub(/\/[^\/]*$/, "")
|
||||
File.rename(body, "#{bodybase}/ripnewsdecode")
|
||||
|
|
@ -319,12 +321,15 @@ def output_data(subject, mode, filename="", body="")
|
|||
end
|
||||
end
|
||||
|
||||
def check_ext(filename, mode)
|
||||
def check_ext(group, filename, mode)
|
||||
print "filename: #{filename}\n";
|
||||
case mode
|
||||
when "s"
|
||||
return @config.has_key?("-S") ? filename =~ /\.(#{@config["-S"]})$/ : true
|
||||
print "sould have extension: #{@config[group]["-S"]}\n";
|
||||
return @config.has_key?("-S") ? filename =~ /\.(#{@config[group]["-S"]})$/ : true
|
||||
when "m"
|
||||
return @config.has_key?("-M") ? filename =~ /\.(#{@config["-M"]})$/ : true
|
||||
print "sould have extension: #{@config[group]["-M"]}\n";
|
||||
return @config.has_key?("-M") ? filename =~ /\.(#{@config[group]["-M"]})$/ : true
|
||||
else
|
||||
print "Illegal mode \"#{mode}\" in check_ext\n"
|
||||
exit
|
||||
|
|
@ -393,7 +398,7 @@ for group in @config.keys.sort
|
|||
if @articles.group_is_complete(i)
|
||||
begin
|
||||
if @articles.group_is_singlepart(i)
|
||||
mode, filename, body = get_single(i)
|
||||
mode, filename, body = get_single(i, group)
|
||||
elsif @articles.group_is_multipart(i)
|
||||
mode, filename, body = get_multi(i, group)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue