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
|
#!/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$
|
# $Source$
|
||||||
|
|
||||||
require 'date'
|
require 'date'
|
||||||
|
|
@ -222,17 +222,17 @@ def check_config
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_single(subj)
|
def get_single(subj, group)
|
||||||
print "Fetching singlepart article: #{subj}\n"
|
print "Fetching singlepart article: #{subj}\n"
|
||||||
body = @articles.get_group_body(subj)
|
body = @articles.get_group_body(subj)
|
||||||
if @articles.is_uuencoded(body)
|
if @articles.is_uuencoded(body)
|
||||||
mode, filename, body = @articles.uudecode(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
|
return mode, filename, body
|
||||||
end
|
end
|
||||||
if @articles.is_yencoded(body)
|
if @articles.is_yencoded(body)
|
||||||
mode, filename, body = @articles.ydecode(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
|
return mode, filename, body
|
||||||
end
|
end
|
||||||
print " Unknown encoding (not UU, not yEnc), skipping...\n"
|
print " Unknown encoding (not UU, not yEnc), skipping...\n"
|
||||||
|
|
@ -245,11 +245,11 @@ def get_multi(subj, group)
|
||||||
body = @articles.get_group_body(subj)
|
body = @articles.get_group_body(subj)
|
||||||
if @articles.is_uuencoded(body)
|
if @articles.is_uuencoded(body)
|
||||||
mode, filename, body = @articles.uudecode(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
|
return mode, filename, body
|
||||||
elsif @articles.is_yencoded(body)
|
elsif @articles.is_yencoded(body)
|
||||||
mode, filename, body = @articles.ydecode(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
|
return mode, filename, body
|
||||||
end
|
end
|
||||||
print " Unknown encoding (not UU, not yEnc), skipping...\n"
|
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)
|
if @articles.is_uuencoded(body) or @articles.is_yencoded(body)
|
||||||
file = Tempfile.new("riptmp", @config[group]["TEMPDIR"])
|
file = Tempfile.new("riptmp", @config[group]["TEMPDIR"])
|
||||||
body.collect{|x| file.print "#{x}\n"}
|
body.collect{|x| file.print "#{x}\n"}
|
||||||
|
# hire moet een extensie check!!!
|
||||||
return false unless @articles.get_group_body_rest(subj, file)
|
return false unless @articles.get_group_body_rest(subj, file)
|
||||||
fileout = Tempfile.new("riptmp", @config[group]["TEMPDIR"])
|
fileout = Tempfile.new("riptmp", @config[group]["TEMPDIR"])
|
||||||
if @articles.is_uuencoded(body)
|
if @articles.is_uuencoded(body)
|
||||||
|
|
@ -266,7 +267,8 @@ def get_multi(subj, group)
|
||||||
elsif @articles.is_yencoded(body)
|
elsif @articles.is_yencoded(body)
|
||||||
mode, filename, body = @articles.ydecode(file, fileout)
|
mode, filename, body = @articles.ydecode(file, fileout)
|
||||||
end
|
end
|
||||||
return false unless check_ext(filename, "m")
|
# in plaats van hier
|
||||||
|
return false unless check_ext(group, filename, "m")
|
||||||
body = fileout.path
|
body = fileout.path
|
||||||
bodybase = body.sub(/\/[^\/]*$/, "")
|
bodybase = body.sub(/\/[^\/]*$/, "")
|
||||||
File.rename(body, "#{bodybase}/ripnewsdecode")
|
File.rename(body, "#{bodybase}/ripnewsdecode")
|
||||||
|
|
@ -319,12 +321,15 @@ def output_data(subject, mode, filename="", body="")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_ext(filename, mode)
|
def check_ext(group, filename, mode)
|
||||||
|
print "filename: #{filename}\n";
|
||||||
case mode
|
case mode
|
||||||
when "s"
|
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"
|
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
|
else
|
||||||
print "Illegal mode \"#{mode}\" in check_ext\n"
|
print "Illegal mode \"#{mode}\" in check_ext\n"
|
||||||
exit
|
exit
|
||||||
|
|
@ -393,7 +398,7 @@ for group in @config.keys.sort
|
||||||
if @articles.group_is_complete(i)
|
if @articles.group_is_complete(i)
|
||||||
begin
|
begin
|
||||||
if @articles.group_is_singlepart(i)
|
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)
|
elsif @articles.group_is_multipart(i)
|
||||||
mode, filename, body = get_multi(i, group)
|
mode, filename, body = get_multi(i, group)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue