{"type":"rich","version":"1.0","provider_name":"phorkie","provider_url":"https:\/\/p.cweiske.de\/","title":"prosody stanza parse xml","author_name":"Christian Weiske","cache_age":86400,"width":900,"height":900,"html":"<!-- embedding all files of https:\/\/p.cweiske.de\/84 -->\n<link rel=\"stylesheet\" href=\"https:\/\/p.cweiske.de\/css\/embed.css\"\/>\n<div class=\"phork\" id=\"84\">\n    <div class=\"phork-file\">\n <div class=\"phork-content\">\n  \n<div class=\"document\">\n\n\n<p>support custom HTML messages in prosody's mod_post_msg plugin.<\/p>\n<p>has been integrated into prosody_modules; see <a class=\"reference external\" href=\"https:\/\/code.google.com\/p\/prosody-modules\/source\/detail?r=e556219cb43d7af6f2a0564e8abf8a614e661be0\">https:\/\/code.google.com\/p\/prosody-modules\/source\/detail?r=e556219cb43d7af6f2a0564e8abf8a614e661be0<\/a><\/p>\n<\/div>\n\n <\/div>\n <div class=\"phork-meta\">\n  <a href=\"https:\/\/p.cweiske.de\/84\/rev-raw\/f2edec9ddbe9e7fa117bd63e2fcc662ea1b72790\/README.rst\" style=\"float: right\">view raw source<\/a>\n  <a href=\"https:\/\/p.cweiske.de\/84#README.rst\">README.rst<\/a>\n <\/div>\n<\/div>\n    <div class=\"phork-file\">\n <div class=\"phork-content\">\n  <style type=\"text\/css\">\/**\n * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann\n * (http:\/\/qbnz.com\/highlighter\/ and http:\/\/geshi.org\/)\n *\/\n.diff .de1, .diff .de2 {font: normal normal 1em\/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}\n.diff  {font-family:monospace;}\n.diff .imp {font-weight: bold; color: red;}\n.diff li, .diff .li1 {color: #DDD;}\n.diff .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}\n.diff .kw1 {color: #aaaaaa; font-style: italic;}\n.diff .re0 {color: #440088;}\n.diff .re1 {color: #991111;}\n.diff .re2 {color: #00b000;}\n.diff .re3 {color: #888822;}\n.diff .re4 {color: #888822;}\n.diff .re5 {color: #0011dd;}\n.diff .re6 {color: #440088;}\n.diff .re7 {color: #991111;}\n.diff .re8 {color: #00b000;}\n.diff .re9 {color: #888822;}\n.diff span.xtra { display:block; }\n<\/style><div class=\"code\"><table class=\"diff\"><tbody><tr class=\"li1\"><td class=\"ln\"><pre class=\"de1\">1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n<\/pre><\/td><td class=\"de1\"><pre class=\"de1\">&#160;HG changeset patch\n# User Christian Weiske &lt;cweiske@cweiske.de&gt;\n# Date <span class=\"nu0\">1392386891<\/span> -<span class=\"nu0\">3600<\/span>\n# Node ID 46f6f3b<span class=\"re0\">7c8926<\/span>da<span class=\"re0\">0d79<\/span>fee2457b25936f33f<span class=\"re0\">98d4<\/span>\n# Parent &#160;<span class=\"re0\">9700c89<\/span>f7bf67cc27862743f46f1192e<span class=\"re0\">0a1069<\/span>e9\nmod_post_msg: add support for HTML messages\n&#160;\ndiff -r <span class=\"re0\">9700c89<\/span>f7bf6 -r 46f6f3b<span class=\"re0\">7c892<\/span> mod_post_msg\/mod_post_msg.lua\n<span class=\"re3\">--- a\/mod_post_msg\/mod_post_msg.lua &#160; &#160; Thu Jan 23 20:27:14 2014 +0000<\/span>\n<span class=\"re4\">+++ b\/mod_post_msg\/mod_post_msg.lua &#160; &#160; Fri Feb 14 15:08:11 2014 +0100<\/span>\n<span class=\"re6\">@@ -6,6 +6,7 @@<\/span>\n&#160;local test_password = require &quot;core.usermanager&quot;.test_password;\n&#160;local b64_decode = require &quot;util.encodings&quot;.base64.decode;\n&#160;local formdecode = require &quot;net.http&quot;.formdecode;\n<span class=\"re8\">+local xml = require&quot;util.xml&quot;;<\/span>\n&#160;\n&#160;local function require_valid_user<span class=\"br0\">&#40;<\/span>f<span class=\"br0\">&#41;<\/span>\n&#160; &#160; &#160; &#160; return function<span class=\"br0\">&#40;<\/span>event, path<span class=\"br0\">&#41;<\/span>\n<span class=\"re6\">@@ -46,8 +47,16 @@<\/span>\n&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; end\n&#160; &#160; &#160; &#160; elseif body_type == &quot;application\/x-www-form-urlencoded&quot; then\n&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; local post_body = formdecode<span class=\"br0\">&#40;<\/span>request.body<span class=\"br0\">&#41;<\/span>;\n<span class=\"re7\">- &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; message = msg<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#123;<\/span> to = post_body.to or to, from = authed_user,<\/span>\n<span class=\"re8\">+ &#160; &#160; &#160; &#160; &#160; &#160; &#160; message = msg<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#123;<\/span> to = post_body.to or to, from = authed_user,<\/span>\n&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; type = post_body.type or &quot;chat&quot;<span class=\"br0\">&#125;<\/span>, post_body.body<span class=\"br0\">&#41;<\/span>;\n<span class=\"re8\">+ &#160; &#160; &#160; &#160; &#160; &#160; &#160; if post_body.html then<\/span>\n<span class=\"re8\">+ &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;local html, err = xml.parse<span class=\"br0\">&#40;<\/span>post_body.html<span class=\"br0\">&#41;<\/span>;<\/span>\n<span class=\"re8\">+ &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;if not html then<\/span>\n<span class=\"re8\">+ &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; module:log<span class=\"br0\">&#40;<\/span>&quot;warn&quot;, &quot;mod_post_msg: invalid XML: %s&quot;, err<span class=\"br0\">&#41;<\/span>;<\/span>\n<span class=\"re8\">+ &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; return <span class=\"nu0\">400<\/span>;<\/span>\n<span class=\"re8\">+ &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;end<\/span>\n<span class=\"re8\">+ &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;message:tag<span class=\"br0\">&#40;<\/span>&quot;html&quot;, <span class=\"br0\">&#123;<\/span>xmlns=&quot;http:\/\/jabber.org\/protocol\/xhtml-im&quot;<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span>:add_child<span class=\"br0\">&#40;<\/span>html<span class=\"br0\">&#41;<\/span>:up<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span>;<\/span>\n<span class=\"re8\">+ &#160; &#160; &#160; &#160; &#160; &#160; &#160; end<\/span>\n&#160; &#160; &#160; &#160; else\n&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; return <span class=\"nu0\">415<\/span>;\n&#160; &#160; &#160; &#160; end\n&#160;<\/pre><\/td><\/tr><\/tbody><\/table><\/div>\n <\/div>\n <div class=\"phork-meta\">\n  <a href=\"https:\/\/p.cweiske.de\/84\/rev-raw\/f2edec9ddbe9e7fa117bd63e2fcc662ea1b72790\/mod_post_msg.lua.diff\" style=\"float: right\">view raw source<\/a>\n  <a href=\"https:\/\/p.cweiske.de\/84#mod_post_msg.lua.diff\">mod_post_msg.lua.diff<\/a>\n <\/div>\n<\/div>\n<\/div>\n"}
