Skip to content

Commit

Permalink
strip inputs from command line and fix password setting test
Browse files Browse the repository at this point in the history
  • Loading branch information
rvojcik committed Apr 21, 2015
1 parent 0099572 commit f96fbbc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions email-manage-free.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ def delete_object(domain, mailbox):
def add_object(domain, mailbox):
"""Add domain or mailbox to iRedMail"""
if domain:
# Remove whitespace chars
domain = domain.strip()

if not iredutils.is_domain(domain):
exit_script("Invalid domain name", 1)
Expand Down Expand Up @@ -216,6 +218,8 @@ def add_object(domain, mailbox):


elif mailbox:
# Remove whitespace chars
mailbox = mailbox.strip()

if not iredutils.is_email(mailbox):
exit_script("Invalid email", 1)
Expand Down Expand Up @@ -296,6 +300,10 @@ def action_add_alias(address, send_to):
exit_script("Alias address not specified", 1)
if not send_to:
exit_script("Alias destination address not specified", 1)
# Remove whitespaces
address = address.strip()
send_to = send_to.strip()

domain = address.split('@')[1]

if iredutils.is_domain(domain):
Expand Down
13 changes: 13 additions & 0 deletions email-manage-pro.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ def delete_object(domain, mailbox):
def add_object(domain, mailbox):
"""Add domain or mailbox to iRedMail"""
if domain:
# Remove whitespace chars
domain = domain.strip()

if not iredutils.is_domain(domain):
exit_script("Invalid domain name", 1)
Expand Down Expand Up @@ -216,6 +218,8 @@ def add_object(domain, mailbox):


elif mailbox:
# Remove whitespace chars
mailbox = mailbox.strip()

if not iredutils.is_email(mailbox):
exit_script("Invalid email", 1)
Expand Down Expand Up @@ -296,6 +300,10 @@ def action_add_alias(address, send_to):
exit_script("Alias address not specified", 1)
if not send_to:
exit_script("Alias destination address not specified", 1)
# Remove whitespaces
address = address.strip()
send_to = send_to.strip()

domain = address.split('@')[1]

if iredutils.is_domain(domain):
Expand Down Expand Up @@ -339,6 +347,11 @@ def action_changepass(mailbox, pass_from_prompt):
random_string = iredutils.generate_random_strings()
# Prepare plain or encrypted password
pwscheme = None
try:
settings.STORE_PASSWORD_IN_PLAIN_TEXT
except:
settings.STORE_PASSWORD_IN_PLAIN_TEXT = False

if settings.STORE_PASSWORD_IN_PLAIN_TEXT:
pwscheme = 'PLAIN'
password = iredpwd.generate_password_hash(random_string, pwscheme=pwscheme)
Expand Down

0 comments on commit f96fbbc

Please sign in to comment.