Re: [pgadmin-hackers] Email validation in setup.py [pgadmin4]

2016-06-10 Thread Dave Page
Thanks, applied.

On Thu, Jun 9, 2016 at 8:41 AM, Harshal Dhumal
 wrote:
> Hi,
>
> PFA patch for email validation in setup.py
>
> --
> Harshal Dhumal
> Software Engineer
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>



-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] Email validation in setup.py [pgadmin4]

2016-06-09 Thread Harshal Dhumal
Hi,

PFA patch for email validation in setup.py

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/setup.py b/web/setup.py
index 4ea28e1..5f13e83 100644
--- a/web/setup.py
+++ b/web/setup.py
@@ -15,6 +15,7 @@ import sys
 import getpass
 import random
 import string
+import re
 
 from flask import Flask
 from flask.ext.security import Security, SQLAlchemyUserDatastore
@@ -48,9 +49,15 @@ def do_setup(app):
 print("""
 Enter the email address and password to use for the initial pgAdmin user \
 account:\n""")
+email_filter = re.compile(
+"^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9]"
+"(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9]"
+"(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
+
 email = ''
-while email == '':
-email = input("Email address: ")
+input("Email address: ")
+while email == '' or not email_filter.match(email):
+email = input("Invalid Email address: ")
 
 def pprompt():
 return getpass.getpass(), getpass.getpass('Retype password:')

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers