comparison mod_pastebin/mod_pastebin.lua @ 189:16d367e3c04e

mod_pastebin: Fix to not truncate UTF-8 sequences when creating a snippet summary for XHTML-IM (thanks DaiZW for discovering :) )
author Matthew Wild <mwild1@gmail.com>
date Mon, 28 Jun 2010 14:54:30 +0100
parents 0d37d18ea073
children 7a695ee3884b
comparison
equal deleted inserted replaced
188:5e8ea3733dc6 189:16d367e3c04e
72 local url = pastebin_text(body); 72 local url = pastebin_text(body);
73 module:log("debug", "Pasted message as %s", url); 73 module:log("debug", "Pasted message as %s", url);
74 --module:log("debug", " stanza[bodyindex] = %q", tostring( stanza[bodyindex])); 74 --module:log("debug", " stanza[bodyindex] = %q", tostring( stanza[bodyindex]));
75 stanza[bodyindex][1] = url; 75 stanza[bodyindex][1] = url;
76 local html = st.stanza("html", { xmlns = xmlns_xhtmlim }):tag("body", { xmlns = xmlns_xhtml }); 76 local html = st.stanza("html", { xmlns = xmlns_xhtmlim }):tag("body", { xmlns = xmlns_xhtml });
77 html:tag("p"):text(body:sub(1,150)):up(); 77 html:tag("p"):text(body:sub(1,150):gsub("[\128-\255]+$", "")):up();
78 html:tag("a", { href = url }):text("[...]"):up(); 78 html:tag("a", { href = url }):text("[...]"):up();
79 stanza[htmlindex or #stanza+1] = html; 79 stanza[htmlindex or #stanza+1] = html;
80 end 80 end
81 end 81 end
82 82