Module: check_mk
Branch: master
Commit: e2739210157b94e8ac93311d976050f42fa1c030
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e2739210157b94…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Nov 4 10:25:28 2014 +0100
New option forbidden_characters for TextAscii
---
web/htdocs/valuespec.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 4c71444..dc72c4d 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -349,12 +349,12 @@ class TextAscii(ValueSpec):
self._empty_text = kwargs.get("empty_text", "")
self._read_only = kwargs.get("read_only")
self._none_is_empty = kwargs.get("none_is_empty", False)
+ self._forbidden_chars = kwargs.get("forbidden_chars", "")
self._regex = kwargs.get("regex")
self._regex_error = kwargs.get("regex_error",
_("Your input does not match the required format."))
if type(self._regex) == str:
self._regex = re.compile(self._regex)
-
self._prefix_buttons = kwargs.get("prefix_buttons", [])
def canonical_value(self):
@@ -419,6 +419,10 @@ class TextAscii(ValueSpec):
unicode(value)
except:
raise MKUserError(varprefix, _("Non-ASCII characters are not allowed
here."))
+ if self._forbidden_chars:
+ for c in self._forbidden_chars:
+ if c in value:
+ raise MKUserError(varprefix, _("The character
<tt>%s</tt> is not allowed here.") % c)
if self._none_is_empty and value == "":
raise MKUserError(varprefix, _("An empty value must be represented with
None here."))
if not self._allow_empty and value.strip() == "":