Skip to content

Commit c2e8d37

Browse files
committed
Improve error handling
1 parent 1a6f45b commit c2e8d37

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

easybuggy/views.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from email.mime.multipart import MIMEMultipart
1313
from email.mime.text import MIMEText
1414
from time import sleep
15-
15+
from validate_email import validate_email
1616
import numpy as np
1717
import psutil
1818
import requests
@@ -457,7 +457,7 @@ def xss(request):
457457
}
458458
if request.method == 'POST':
459459
input_str = request.POST.get("string")
460-
if input_str is not None and input_str is not '':
460+
if input_str is not None and input_str is not '':
461461
d['msg'] = input_str[::-1]
462462
return render(request, 'xss.html', d)
463463

@@ -778,7 +778,7 @@ def csrf(request):
778778
d['complete'] = True
779779
except Exception as e:
780780
logger.exception('Exception occurs: %s', e)
781-
d['msg'] = _('msg.passwd.change.failed')
781+
d['errmsg'] = _('msg.passwd.change.failed')
782782
return render(request, 'csrf.html', d)
783783

784784

@@ -793,7 +793,7 @@ def clickjacking(request):
793793
if request.method == 'POST' and "username" in request.session:
794794
username = request.session["username"]
795795
mail = request.POST.get("mail")
796-
if mail is not None:
796+
if validate_email(mail):
797797
try:
798798
from django.contrib.auth.models import User
799799
User.objects.filter(is_superuser=True)
@@ -803,7 +803,9 @@ def clickjacking(request):
803803
d['complete'] = True
804804
except Exception as e:
805805
logger.exception('Exception occurs: %s', e)
806-
d['msg'] = _('msg.mail.change.failed')
806+
d['errmsg'] = _('msg.mail.change.failed')
807+
else:
808+
d['errmsg'] = _('msg.mail.format. is.invalid')
807809
return render(request, 'clickjacking.html', d)
808810

809811

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ pytz==2018.3
1111
requests==2.18.4
1212
urllib3==1.22
1313
ldap3==2.5
14+
validate_email

0 commit comments

Comments
 (0)