# HG changeset patch # User Matthew Wild # Date 1342983165 -3600 # Node ID 03595194075aa5321395a29a0801a560d84963cc # Parent c68ce6eb97f07bad3552af28b82b3e8d27a1b159 mod_register_web: nodeprep username before creating user (thanks IRON) diff -r c68ce6eb97f0 -r 03595194075a mod_register_web/mod_register_web.lua --- a/mod_register_web/mod_register_web.lua Thu Jul 19 15:33:35 2012 +0100 +++ b/mod_register_web/mod_register_web.lua Sun Jul 22 19:52:45 2012 +0100 @@ -1,4 +1,5 @@ local captcha_options = module:get_option("captcha_options", {}); +local nodeprep = require "util.encodings".stringprep.nodeprep; function generate_captcha(display_options) return (([[ @@ -50,10 +51,11 @@ end function register_user(form) - if usermanager.user_exists(form.username, module.host) then - return nil, "user-exists"; - end - return usermanager.create_user(form.username, form.password, module.host); + local prepped_username = nodeprep(form.username); + if usermanager.user_exists(prepped_username, module.host) then + return nil, "user-exists"; + end + return usermanager.create_user(prepped_username, form.password, module.host); end function generate_success(event, form)