From 76729f2106d7ed8100fb7782885c1a7e6a51edda Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Wed, 11 Sep 2024 10:14:31 +0200 Subject: [PATCH] repair error handling --- changedetectionio/forms.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/changedetectionio/forms.py b/changedetectionio/forms.py index 7f292976..82591dbf 100644 --- a/changedetectionio/forms.py +++ b/changedetectionio/forms.py @@ -325,7 +325,7 @@ class ValidateCSSJSONXPATHInput(object): self.allow_json = allow_json def __call__(self, form, field): - + from lxml.etree import XPathEvalError if isinstance(field.data, str): data = [field.data] else: @@ -349,12 +349,12 @@ class ValidateCSSJSONXPATHInput(object): try: # Call the determined function - res = filter_function(xpath_filter=line.strip(), html_content=form.last_html_for_form_validation) + res = filter_function(xpath_filter=line, html_content=form.last_html_for_form_validation) # It's OK if this is an empty result, we just want to check that it doesn't crash the parser - except elementpath.ElementPathError as e: + except (elementpath.ElementPathError,XPathEvalError) as e: message = field.gettext('\'%s\' is not a valid XPath expression. (%s)') raise ValidationError(message % (line, str(e))) - except: + except Exception as e: raise ValidationError("A system-error occurred when validating your XPath expression") elif 'json:' in line: