From f4a59b2d71736031c0044c78951d5a4f636fafab Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 2 May 2014 15:21:33 +0200 Subject: [PATCH] Support forbidden chars in strings. --- qutebrowser/config/_conftypes.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qutebrowser/config/_conftypes.py b/qutebrowser/config/_conftypes.py index 168ff9c3b..711b7e6cd 100644 --- a/qutebrowser/config/_conftypes.py +++ b/qutebrowser/config/_conftypes.py @@ -156,14 +156,19 @@ class String(BaseType): typestr = 'string' - def __init__(self, minlen=None, maxlen=None): + def __init__(self, minlen=None, maxlen=None, forbidden=None): self.minlen = minlen self.maxlen = maxlen + self.forbidden = forbidden def transform(self, value): return value.lower() def validate(self, value): + if self.forbidden is not None and any(c in value + for c in self.forbidden): + raise ValidationError(value, "may not contain the chars " + "\"{}\"".format(self.forbidden)) if self.minlen is not None and len(value) < self.minlen: raise ValidationError(value, "must be at least {} chars " "long!".format(self.minlen))