diff --git a/changedetectionio/forms.py b/changedetectionio/forms.py index 8703a63f..bee488c5 100644 --- a/changedetectionio/forms.py +++ b/changedetectionio/forms.py @@ -206,12 +206,6 @@ class ValidateJinja2Template(object): from jinja2 import Environment, BaseLoader, TemplateSyntaxError from jinja2.meta import find_undeclared_variables - regex = re.compile('{{(.*?)}}') - valid_tokens = list(notification.valid_tokens.keys()) - for p in re.findall(regex, field.data): - if not p.strip() in valid_tokens: - message = field.gettext('Token \'%s\' is not a valid token or is unknown') - raise ValidationError(message % (p)) try: jinja2_env = Environment(loader=BaseLoader) diff --git a/changedetectionio/store.py b/changedetectionio/store.py index 9d555f8b..6a082c35 100644 --- a/changedetectionio/store.py +++ b/changedetectionio/store.py @@ -624,23 +624,25 @@ class ChangeDetectionStore: return # Convert old static notification tokens to jinja2 tokens - def update_11(self): + def update_10(self): # Each watch import re + # only { } not {{ or }} + r = r'(?}}', n_body) + watch['notification_body'] = re.sub(r, '{{\g<1>}}', n_body) n_title = watch.get('notification_title') if n_title: - self.data['settings']['application']['notification_title'] = re.sub(r'{(\w+)}{1}', '{{\g<1>}}', n_title) + self.data['settings']['application']['notification_title'] = re.sub(r, '{{\g<1>}}', n_title) n_urls = watch.get('notification_urls') if n_urls: for i, url in enumerate(n_urls): - watch['notification_urls'][i] = re.sub(r'{(\w+)}{1}', '{{\g<1>}}', url) + watch['notification_urls'][i] = re.sub(r, '{{\g<1>}}', url) except: continue @@ -648,15 +650,15 @@ class ChangeDetectionStore: # System wide n_body = self.data['settings']['application'].get('notification_body') if n_body: - self.data['settings']['application']['notification_body'] = re.sub(r'{(\w+)}{1}', '{{\g<1>}}', n_body) + self.data['settings']['application']['notification_body'] = re.sub(r, '{{\g<1>}}', n_body) n_title = self.data['settings']['application'].get('notification_title') if n_body: - self.data['settings']['application']['notification_title'] = re.sub(r'{(\w+)}{1}', '{{\g<1>}}', n_title) + self.data['settings']['application']['notification_title'] = re.sub(r, '{{\g<1>}}', n_title) n_urls = self.data['settings']['application'].get('notification_urls') if n_urls: for i, url in enumerate(n_urls): - self.data['settings']['application']['notification_urls'][i] = re.sub(r'{(\w+)}{1}', '{{\g<1>}}', url) + self.data['settings']['application']['notification_urls'][i] = re.sub(r, '{{\g<1>}}', url) return