Module: check_mk
Branch: master
Commit: edd59ab4ec4249fda85c1d0c94c34749177277d3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=edd59ab4ec4249…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Fri Feb 23 11:45:13 2018 +0100
Use EmailAddress valuespec in From and Reply-To of HTML Email and simplify EmailAddress
regex
Change-Id: I0a3ae060b27ea99e8d49d44783931c14add5cee3
---
web/htdocs/valuespec.py | 5 ++---
web/plugins/wato/notifications.py | 4 ++--
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 0a023d4..6c88b8c 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -626,7 +626,6 @@ class RegExpUnicode(TextUnicode, RegExp):
ValueSpec.custom_validate(self, value, varprefix)
-
class EmailAddress(TextAscii):
def __init__(self, **kwargs):
kwargs.setdefault("size", 40)
@@ -634,7 +633,7 @@ class EmailAddress(TextAscii):
# The "new" top level domains are very unlimited in length.
Theoretically they can be
# up to 63 chars long. But currently the longest is 24 characters. Check this out
with:
# wget -qO -
http://data.iana.org/TLD/tlds-alpha-by-domain.txt | tail -n+2 | wc
-L
- self._regex =
re.compile('^[A-Z0-9._%+-]+(a)(localhost|[A-Z0-9.-]+\.[A-Z]{2,24})$'})$', re.I)
+ self._regex =
re.compile('^[A-Z0-9._%&+-]+(a)(localhost|[A-Z0-9.-]+\.[A-Z]{2,24})$'2,24})$', re.I)
self._make_clickable = kwargs.get("make_clickable", False)
def value_to_text(self, value):
@@ -651,7 +650,7 @@ class EmailAddressUnicode(TextUnicode, EmailAddress):
def __init__(self, **kwargs):
TextUnicode.__init__(self, **kwargs)
EmailAddress.__init__(self, **kwargs)
- self._regex =
re.compile(r'^[$\w._%+-]+(a)(localhost|[\w.-]+\.[\w]{2,24})$'})$', re.I | re.UNICODE)
+ self._regex =
re.compile(r'^[\w.%&+-]+(a)(localhost|[\w.-]+\.[\w]{2,24})$'2,24})$', re.I |
re.UNICODE)
def validate_value(self, value, varprefix):
TextUnicode.validate_value(self, value, varprefix)
diff --git a/web/plugins/wato/notifications.py b/web/plugins/wato/notifications.py
index 832c203..e4c12fc 100644
--- a/web/plugins/wato/notifications.py
+++ b/web/plugins/wato/notifications.py
@@ -49,14 +49,14 @@ def transform_forth_html_mail_url_prefix(p):
def html_email_parameter_elements():
elements = [
( "from",
- TextAscii(
+ EmailAddress(
title = _("From: Address"),
size = 40,
allow_empty = False,
)
),
( "reply_to",
- TextAscii(
+ EmailAddress(
title = _("Reply-To: Address"),
size = 40,
allow_empty = False,