Skip to content

Commit

Permalink
remove unnecessary/inefficient regular expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
jennyq committed Dec 31, 2023
1 parent 505a1ff commit 080949c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 3 additions & 6 deletions tendenci/apps/base/management/commands/createuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@
from django.db import DEFAULT_DB_ALIAS
from django.utils.translation import gettext as _

RE_VALID_USERNAME = re.compile(r'[\w.@+-]+$')
from tendenci.apps.base.utils import validate_email

EMAIL_RE = re.compile(
r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"' # quoted-string
r')@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}$', re.IGNORECASE) # domain
RE_VALID_USERNAME = re.compile(r'[\w.@+-]+$')


def is_valid_email(value):
if not EMAIL_RE.search(value):
if not validate_email(value):
raise exceptions.ValidationError(_('Enter a valid e-mail address.'))


Expand Down
4 changes: 1 addition & 3 deletions tendenci/apps/events/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2292,9 +2292,7 @@ def clean_first_name(self):
data = self.cleaned_data['first_name']

# detect markup
pattern = re.compile(r'<[^>]*?>', re.I and re.M)
markup = pattern.search(data)
if markup:
if '<' in data and '>' in data:
raise forms.ValidationError(_("Markup is not allowed in the name field"))

# detect URL and Email
Expand Down

0 comments on commit 080949c

Please sign in to comment.