summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-01-27 21:58:30 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-01-27 21:58:30 +0100
commit3b294f9aa35c975b00c4f11d090526eb4ff9c34c (patch)
tree8500ef8811bb5fe754fb1c6ecd6e837c83a82833 /lib/rbot
parentd617583171610f5d9fce1efcff0b5b568ca79086 (diff)
wordlist: strip UTF-8 BOM on load
Some editors put a BOM at the beginning of UTF-8 files, and it's not stripped by Ruby's String#strip, so we have to get rid of it ourselves.
Diffstat (limited to 'lib/rbot')
-rwxr-xr-xlib/rbot/core/utils/wordlist.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/rbot/core/utils/wordlist.rb b/lib/rbot/core/utils/wordlist.rb
index 875a9756..fc341578 100755
--- a/lib/rbot/core/utils/wordlist.rb
+++ b/lib/rbot/core/utils/wordlist.rb
@@ -33,7 +33,8 @@ class Wordlist
File.readlines(wordlist_path)
end
- wordlist.map! { |l| l.strip }
+ # wordlists are assumed to be UTF-8, but we need to strip the BOM, if present
+ wordlist.map! { |l| l.sub("\xef\xbb\xbf",'').strip }
wordlist.reject do |word|
word =~ /\s/ && !opts[:spaces] ||
word.empty?