# HG changeset patch # User Waqas Hussain # Date 1263218346 -18000 # Node ID 678ca4e9a479a85940bc6f52b714e5aae650ca61 # Parent 542335c8a5bca45e5a9a8fc2574b77cfc1508d03 sessionmanager: Added resource prepping, and invalid resource checking to the bind_resource function. diff -r 542335c8a5bc -r 678ca4e9a479 core/sessionmanager.lua --- a/core/sessionmanager.lua Mon Jan 11 17:52:28 2010 +0500 +++ b/core/sessionmanager.lua Mon Jan 11 18:59:06 2010 +0500 @@ -24,6 +24,7 @@ local rm_load_roster = require "core.rostermanager".load_roster; local config_get = require "core.configmanager".get; local nameprep = require "util.encodings".stringprep.nameprep; +local resourceprep = require "util.encodings".stringprep.resourceprep; local fire_event = require "core.eventmanager".fire_event; local add_task = require "util.timer".add_task; @@ -105,7 +106,8 @@ if session.resource then return nil, "cancel", "already-bound", "Cannot bind multiple resources on a single connection"; end -- We don't support binding multiple resources - resource = resource or uuid_generate(); + resource = resourceprep(resource); + resource = resource ~= "" and resource or uuid_generate(); --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing if not hosts[session.host].sessions[session.username] then