From 53745c61e5c756641591fa105afe35ec76a7e5c1 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 12 Apr 2021 02:37:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E5=86=8C=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=90=88=E6=B3=95=E9=82=AE=E7=AE=B1=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/register.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/parts/scenes/register.lua b/parts/scenes/register.lua index f7c20a4c..8be9bf1c 100644 --- a/parts/scenes/register.lua +++ b/parts/scenes/register.lua @@ -1,5 +1,16 @@ local scene={} +local function legalEmail(e) + e=SPLITSTR(e,"@") + if #e~=2 then return false end + if e[1]:sub(-1)=="."or e[2]:sub(-1)=="."then return false end + local e1,e2=SPLITSTR(e[1],"."),SPLITSTR(e[2],".") + if #e1*#e2==0 then return false end + for _,v in next,e1 do if #v==0 then return false end end + for _,v in next,e2 do if #v==0 then return false end end + return true +end + local function register() local username= WIDGET.active.username.value local email= WIDGET.active.email.value @@ -7,7 +18,7 @@ local function register() local password2=WIDGET.active.password2.value if #username==0 then LOG.print(text.noUsername)return - elseif not email:match("^[a-zA-Z0-9_]+@[a-zA-Z0-9_-]+%.[a-zA-Z0-9_]+$")then + elseif not legalEmail(email)then LOG.print(text.wrongEmail)return elseif #password==0 or #password2==0 then LOG.print(text.noPassword)return