Changeset

2832:8c754c61c72e

sessionmanager: Added resource prepping, and invalid resource checking to the bind_resource function.
author Waqas Hussain <waqas20@gmail.com>
date Mon, 11 Jan 2010 18:59:06 +0500
parents 2831:8ee7ec6fc5fc
children 2833:a82bd02d5918
files core/sessionmanager.lua
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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