Skip to content

Instantly share code, notes, and snippets.

@zeen
zeen / lxp.lua
Created September 4, 2010 20:13
local coroutine = coroutine;
local tonumber = tonumber;
local string = string;
local setmetatable, getmetatable = setmetatable, getmetatable;
local pairs = pairs;
local deadroutine = coroutine.create(function() end);
coroutine.resume(deadroutine);
local setmetatable = setmetatable;
local pcall = pcall;
local type = type;
local t_concat = table.concat;
local print = print;
local socket_url = require "socket.url";
local http = require "socket.http";
local ltn12 = require "ltn12";
<?php
/**
* A command line interface for automatic downloads of image feeds
*
* @package easypopulate
* @author Waqas Hussain
* @copyright 2010
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License (v2 only)
*/
-- Prosody IM
-- Copyright (C) 2008-2009 Matthew Wild
-- Copyright (C) 2008-2009 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--
local datamanager = require "util.datamanager";
local log = require "util.logger".init("usermanager");
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";
== 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, 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 });
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
-- 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 = { }