Diff

util/sasl/plain.lua @ 5301:6279caf921f1

util.sasl.{plain,scram,digest-md5}: nodeprep username before passing to callbacks, so callbacks don't have to.
author Waqas Hussain <waqas20@gmail.com>
date Tue, 22 Jan 2013 08:21:05 +0500
parent 5240:864b27ddaa10
child 6777:5de6b93d0190
line wrap: on
line diff
--- a/util/sasl/plain.lua	Sat Jan 12 17:26:50 2013 +0100
+++ b/util/sasl/plain.lua	Tue Jan 22 08:21:05 2013 +0500
@@ -13,6 +13,7 @@
 
 local s_match = string.match;
 local saslprep = require "util.encodings".stringprep.saslprep;
+local nodeprep = require "util.encodings".stringprep.nodeprep;
 local log = require "util.logger".init("sasl");
 
 module "sasl.plain"
@@ -54,6 +55,14 @@
 		return "failure", "malformed-request", "Invalid username or password.";
 	end
 
+	local _nodeprep = self.profile.nodeprep;
+	if _nodeprep ~= false then
+		authentication = (_nodeprep or nodeprep)(authentication);
+		if not authentication or authentication == "" then
+			return "failure", "malformed-request", "Invalid username or password."
+		end
+	end
+
 	local correct, state = false, false;
 	if self.profile.plain then
 		local correct_password;