From 0c3959efb07d5de5604f54f04990a684f144d659 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Sun, 31 Oct 2021 13:47:51 -0400 Subject: [PATCH 1/2] Try this? --- DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py b/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py index 9c887971..78c1efec 100644 --- a/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py +++ b/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py @@ -261,15 +261,17 @@ def find_in_file(string, demo_files_dict, regex=False, verbose=False, window=Non matches = re.finditer(br'^' + bytes(".*("+re.escape(string) + ").*$", 'utf-8'), s, re.MULTILINE) if matches: if show_first_match: - file_list.append(file) - num_files += 1 + #file_list.append(file) + #num_files += 1 match_array = [] matched_str = matches.group(0).decode('utf-8') - if ("==" not in matched_str and "b'" not in matched_str): + if not all(x in matched_str for x in ("b'", '==')): # safe to assume this is not a base64 string as it does not contain the proper ending match_array.append(matches.group(0).decode('utf-8')) matched_dict[full_filename] = match_array + file_list.append(file) + num_files += 1 else: # We need to do this because strings are "falsy" in Python, but empty matches still return True... append_file = False From d3012ea16b2e71e96f3b8848e3ab8d6a3f1d6c37 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Sun, 31 Oct 2021 13:49:20 -0400 Subject: [PATCH 2/2] Fix for bytestring search results --- .../Browser_START_HERE_Demo_Programs_Browser.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py b/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py index 78c1efec..6fe12e1d 100644 --- a/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py +++ b/DemoPrograms/Browser_START_HERE_Demo_Programs_Browser.py @@ -266,7 +266,7 @@ def find_in_file(string, demo_files_dict, regex=False, verbose=False, window=Non match_array = [] matched_str = matches.group(0).decode('utf-8') - if not all(x in matched_str for x in ("b'", '==')): + if not all(x in matched_str for x in ("b'", '=')) and len(matched_str) < 500: # safe to assume this is not a base64 string as it does not contain the proper ending match_array.append(matches.group(0).decode('utf-8')) matched_dict[full_filename] = match_array @@ -277,12 +277,12 @@ def find_in_file(string, demo_files_dict, regex=False, verbose=False, window=Non append_file = False match_array = [] for match_ in matches: - match_str = match_.group(0).decode('utf-8') - if match_str: - if len(match_str) < 500 and "==" not in match_str and "b'" not in match_str: - match_array.append(match_str) - if append_file is False: - append_file = True + matched_str = match_.group(0).decode('utf-8') + if matched_str: + if not all(x in matched_str for x in ("b'", '=')) and len(matched_str) < 500: + # if len(match_str) < 500 and "=" not in match_str and "b'" not in match_str: + match_array.append(matched_str) + append_file = True if append_file: file_list.append(file) num_files += 1