tidy up checksum check ara

pull/419/head
dgtlmoon 3 years ago
parent 4f536bb559
commit 6e00f0e025

@ -124,6 +124,7 @@ class perform_site_check():
# Dont depend on the content-type header here, maybe it's not present # Dont depend on the content-type header here, maybe it's not present
if 'json:' in css_filter_rule: if 'json:' in css_filter_rule:
is_json = True
rule = css_filter_rule.replace('json:', '') rule = css_filter_rule.replace('json:', '')
stripped_text_from_html = html_tools.extract_json_as_string(content=fetcher.content, stripped_text_from_html = html_tools.extract_json_as_string(content=fetcher.content,
jsonpath_filter=rule).encode('utf-8') jsonpath_filter=rule).encode('utf-8')
@ -170,12 +171,18 @@ class perform_site_check():
else: else:
stripped_text_from_html = stripped_text_from_html.encode('utf8') stripped_text_from_html = stripped_text_from_html.encode('utf8')
######## CALCULATE CHECKSUM FOR DIFF DETECTION
# Re #133 - if we should strip whitespaces from triggering the change detected comparison # Re #133 - if we should strip whitespaces from triggering the change detected comparison
if is_text_or_html and self.datastore.data['settings']['application'].get('ignore_whitespace', False): if is_text_or_html:
if self.datastore.data['settings']['application'].get('ignore_whitespace', False):
fetched_md5 = hashlib.md5(stripped_text_from_html.translate(None, b'\r\n\t ')).hexdigest() fetched_md5 = hashlib.md5(stripped_text_from_html.translate(None, b'\r\n\t ')).hexdigest()
else: else:
fetched_md5 = hashlib.md5(stripped_text_from_html).hexdigest() fetched_md5 = hashlib.md5(stripped_text_from_html).hexdigest()
if is_json:
fetched_md5 = hashlib.md5(stripped_text_from_html).hexdigest()
# Goal here in the future is to be able to abstract out different content type checks into their own class # Goal here in the future is to be able to abstract out different content type checks into their own class
if is_binary: if is_binary:

Loading…
Cancel
Save