Skip to content

Instantly share code, notes, and snippets.

digraph foo {
rankdir=LR;
node [ shape = point ];
ENTRY;
en_98;
eof_1;
eof_2;
eof_3;
eof_4;
eof_5;
@zeen
zeen / test.rl
Created December 18, 2009 22:01
#include <stdio.h>
#include <string.h>
%%{
machine foo;
alphtype unsigned char;
action char { printf("> %c\n", *p); } Char = any* @char;
local host = hosts[module.host];
module:hook("presence/full", function(event)
local origin, stanza = event.origin, event.stanza;
local node, host, resource = jid_split(stanza.attr.to);
if not node then return; end -- not to a room
local room = host.muc[node.."@"..host];
local bookmark = {
jid = "[email protected]";
name = "Jabber Support Room";
};
local datamanager = require "util.datamanager";
local st = require "util.stanza";
module:hook("user-registered", function(event)
-- expects XML file as first argument
-- call in a loop over all files
-- e.g., on windows I can do: for %x in (xml\*.xml) do @ j2offline.lua %x
-- prosody stuff needs to be on LUA_PATH and LUA_CPATH, or add it here:
package.path = "../?.lua;"..package.path;
package.cpath = "../?.dll;../?.so;"..package.cpath;
prosody = { }
diff --git a/util/sasl_cyrus.lua b/util/sasl_cyrus.lua
--- a/util/sasl_cyrus.lua
+++ b/util/sasl_cyrus.lua
@@ -97,6 +97,9 @@
local data;
if self.mechanism then
+ if self.mechanism == "PLAIN" then
+ message = (message or ""):match("(%z.*)");
+ end
diff --git a/util/sasl_cyrus.lua b/util/sasl_cyrus.lua
--- a/util/sasl_cyrus.lua
+++ b/util/sasl_cyrus.lua
@@ -97,6 +97,9 @@
local data;
if self.mechanism then
+ if self.mechanism == "PLAIN" then
+ message = (message or ""):match("(%z.*)");
+ end
local st, uuid = require "util.stanza", require "util.uuid";
local xmlns_cmd = "http://jabber.org/protocol/commands";
local states = {}
local _M = {};
function _cmdtag(desc, status, sessionid, action)
local cmd = st.stanza("command", { xmlns = xmlns_cmd, node = desc.node, status = status });
== Pseudo-code for a new caps hash algorithm ==
- Not susceptible to trivial preimage attacks
- No escaping required
- Can be implemented efficiently
- Pseudo-code uses functional primitives, but easily translatable to non-functional languages (like C)
- No undefined edge cases, everything fully specified, including when attributes/elements are missing or duplicated
- 'ver' based on JSON-isque delimiters, using null byte '\0' as escape
- Possibly controversial aspects:
- Concious decision to not fail on missing required elements/attributes
local st = require "util.stanza";
local lxp = require "lxp";
-- XML parser
local parse_xml = (function()
local ns_prefixes = {
["http://www.w3.org/XML/1998/namespace"] = "xml";
};
local ns_separator = "\1";