summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-21 00:48:34 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-21 00:48:34 +0000
commit3d662886107ebcebd1608ee710b8130adbdbea35 (patch)
treeafa6fcb8e67a6426fd30cdff979675f1e0a4ddbc /data
parentcdf9e42440aded117418471425e4e4b8a783986e (diff)
unicode plugin: fix bug with //ignore in/out transcoding option, and add iso-8859-15 fallback in encoding.charsets defaults, to prevent input strings containing unmapped cp1252 octets from crashing the bot
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/unicode.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/data/rbot/plugins/unicode.rb b/data/rbot/plugins/unicode.rb
index e45e44a4..a46b6779 100644
--- a/data/rbot/plugins/unicode.rb
+++ b/data/rbot/plugins/unicode.rb
@@ -24,21 +24,21 @@ class UnicodePlugin < Plugin
:on_change => Proc.new { |bot, v| reconfigure_filter(bot) })
BotConfig.register BotConfigArrayValue.new(
- 'encoding.charsets', :default => ['utf-8', 'cp1252'],
+ 'encoding.charsets', :default => ['utf-8', 'cp1252', 'iso-8859-15'],
:desc => "Ordered list of iconv(3) charsets the bot should try",
:on_change => Proc.new { |bot, v| reconfigure_filter(bot) })
class UnicodeFilter
def initialize(oenc, *iencs)
o = oenc.dup
- o += '//ignore' if !o.include?('/')
+ # o += '//ignore' if !o.include?('/')
i = iencs[0].dup
- i += '//ignore' if !i.include?('/')
+ # i += '//ignore' if !i.include?('/')
@iencs = iencs.dup
@iconvs = @iencs.map { |_| Iconv.new('utf-8', _) }
debug "*** o = #{o}, i = #{i}, iencs = #{iencs.inspect}"
- @default_in = Iconv.new('utf-8', i)
- @default_out = Iconv.new(o, 'utf-8')
+ @default_in = Iconv.new('utf-8//ignore', i)
+ @default_out = Iconv.new(o, 'utf-8//ignore')
end
def in(data)
@@ -53,7 +53,7 @@ class UnicodePlugin < Plugin
}
rv = @default_in.iconv(data) if !rv
- debug ">> #{rv}"
+ debug ">> #{rv.inspect}"
return rv
end