diff --git a/content.py b/content.py index f4b5efe60..b4b08cb02 100644 --- a/content.py +++ b/content.py @@ -1359,6 +1359,16 @@ def extract_media_in_form_post(post_bytes, boundary, name: str): return media_bytes, post_bytes[:image_start_location] + remainder +def _valid_follows_csv(content: str) -> bool: + """is the given content a valid csv file containing imported follows? + """ + if ',' not in content: + return False + if 'Account address,' not in content: + return False + return True + + def save_media_in_form_post(media_bytes, debug: bool, filename_base: str = None) -> (str, str): """Saves the given media bytes extracted from http form POST @@ -1396,7 +1406,7 @@ def save_media_in_form_post(media_bytes, debug: bool, filename = None # directly search the binary array for the beginning - # of an image + # of an image, zip or csv extension_list = { 'png': 'image/png', 'jpeg': 'image/jpeg', @@ -1472,7 +1482,7 @@ def save_media_in_form_post(media_bytes, debug: bool, elif detected_extension == 'csv': csv_str = media_bytes[start_pos:] csv_str = svg_str.decode() - if ',' not in csv_str: + if not _valid_follows_csv(csv_str): return None, None try: