diff --git a/pkg/docker/entrypoint.sh b/pkg/docker/entrypoint.sh index 925067939..9fe5da0ba 100755 --- a/pkg/docker/entrypoint.sh +++ b/pkg/docker/entrypoint.sh @@ -43,10 +43,19 @@ if [ ! -f /var/lib/pgadmin/pgadmin4.db ]; then exit 1 fi - if ! echo "${PGADMIN_DEFAULT_EMAIL}" | grep -E "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$" > /dev/null; then + # Validate PGADMIN_DEFAULT_EMAIL + CHECK_EMAIL_DELIVERABILITY="False" + if [ -n "${PGADMIN_CONFIG_CHECK_EMAIL_DELIVERABILITY}" ]; then + CHECK_EMAIL_DELIVERABILITY=${PGADMIN_CONFIG_CHECK_EMAIL_DELIVERABILITY} + fi + + is_valid_email=$(cd /pgadmin4/pgadmin/utils && /venv/bin/python3 -c "from validation_utils import validate_email; val = validate_email('${PGADMIN_DEFAULT_EMAIL}', ${CHECK_EMAIL_DELIVERABILITY}); print(val)") + if echo "${is_valid_email}" | grep "False" > /dev/null; then echo "'${PGADMIN_DEFAULT_EMAIL}' does not appear to be a valid email address. Please reset the PGADMIN_DEFAULT_EMAIL environment variable and try again." exit 1 fi + # Switch back to root directory for further process + cd /pgadmin4 # Read secret contents if [ -n "${PGADMIN_DEFAULT_PASSWORD_FILE}" ]; then diff --git a/web/pgadmin/utils/csv.py b/web/pgadmin/utils/csv_lib.py similarity index 100% rename from web/pgadmin/utils/csv.py rename to web/pgadmin/utils/csv_lib.py diff --git a/web/pgadmin/utils/driver/psycopg3/connection.py b/web/pgadmin/utils/driver/psycopg3/connection.py index f61cfad69..11a1865a9 100644 --- a/web/pgadmin/utils/driver/psycopg3/connection.py +++ b/web/pgadmin/utils/driver/psycopg3/connection.py @@ -35,7 +35,7 @@ from .typecast import register_global_typecasters,\ register_string_typecasters, register_binary_typecasters, \ register_array_to_string_typecasters, ALL_JSON_TYPES from .encoding import get_encoding, configure_driver_encodings -from pgadmin.utils import csv +from pgadmin.utils import csv_lib as csv from pgadmin.utils.master_password import get_crypt_key from io import StringIO from pgadmin.utils.locker import ConnectionLocker diff --git a/web/pgadmin/utils/validation_utils.py b/web/pgadmin/utils/validation_utils.py index 7d06c349c..8dff88e5c 100644 --- a/web/pgadmin/utils/validation_utils.py +++ b/web/pgadmin/utils/validation_utils.py @@ -9,14 +9,17 @@ from email_validator import validate_email as email_validate, \ EmailNotValidError -import config -def validate_email(email): +def validate_email(email, check_email_deliverability=None): try: + if check_email_deliverability is None: + import config + check_email_deliverability = config.CHECK_EMAIL_DELIVERABILITY + # Validate. _ = email_validate( - email, check_deliverability=config.CHECK_EMAIL_DELIVERABILITY) + email, check_deliverability=check_email_deliverability) # Update with the normalized form. return True