From d617583171610f5d9fce1efcff0b5b568ca79086 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 27 Jan 2009 21:54:59 +0100 Subject: wordlist: exist? method The new Wordlist.exist? method can be used to check if a wordlist file exists. It will refuse to check upstream of the wordlist base directory --- lib/rbot/core/utils/wordlist.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/rbot/core/utils/wordlist.rb b/lib/rbot/core/utils/wordlist.rb index 63cc99a7..875a9756 100755 --- a/lib/rbot/core/utils/wordlist.rb +++ b/lib/rbot/core/utils/wordlist.rb @@ -52,6 +52,14 @@ class Wordlist name[striplen..-1] } end + + def self.exist?(path) + fn = path.to_s + # refuse to check outside of the wordlist base directory + return false if fn =~ /\.\.\// + File.exist?(File.join(self.wordlist_base, fn)) + end + end end end -- cgit v1.2.3