# HG changeset patch # User Matthew Wild # Date 1323381714 0 # Node ID e851f386c9046f77154824b2603e5c239b6282c5 # Parent bd08727378be12405a384e4174c4b67c20140531 mod_pastebin: Threshold is now UTF-8 characters (thanks Grom_PE for initial patch) diff -r bd08727378be -r e851f386c904 mod_pastebin/mod_pastebin.lua --- a/mod_pastebin/mod_pastebin.lua Thu Dec 08 08:17:36 2011 +0000 +++ b/mod_pastebin/mod_pastebin.lua Thu Dec 08 22:01:54 2011 +0000 @@ -19,6 +19,11 @@ return seq; end +local function utf8_length(str) + local _, count = string.gsub(str, "[^\128-\193]", ""); + return count; +end + local pastebin_private_messages = module:get_option_boolean("pastebin_private_messages", hosts[module.host].type ~= "component"); local length_threshold = module:get_option_number("pastebin_threshold", 500); local line_threshold = module:get_option_number("pastebin_line_threshold", 4); @@ -78,7 +83,8 @@ --module:log("debug", "Body(%s) length: %d", type(body), #(body or "")); if body and ( - (#body > length_threshold) or + ((#body > length_threshold) + and (length_utf8(body) > length_threshold)) or (trigger_string and body:find(trigger_string, 1, true) == 1) or (select(2, body:gsub("\n", "%0")) >= line_threshold) ) then