⛰ fix: prevent large string content in error message

This commit is contained in:
Florian Hönicke
2023-05-24 01:17:28 +02:00
parent d9b590045d
commit 8b3270f694
3 changed files with 26 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
import os
import platform
import string
import re
if platform.system() == "Windows":
os.system("color")
@@ -39,4 +40,10 @@ def get_template_parameters(formatted_string):
if field_name is not None:
parameters.append(field_name)
return parameters
return parameters
def clean_large_words(text):
"""Large words like base64 strings are returned by omitting the middle part of the word."""
pattern = r'\b([a-zA-Z0-9+/]{20})([a-zA-Z0-9+/]{200,})([a-zA-Z0-9+/]{20})\b'
cleaned_text = re.sub(pattern, r'\1...\3', text)
return cleaned_text