Skip to content

Commit

Permalink
Merge pull request #71 from gadcam/patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
alufers authored Jul 1, 2023
2 parents 29b12c9 + 93a7356 commit bd836a7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions mitmproxy2swagger/mitmproxy_capture_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@ def mitmproxy_dump_file_huristic(file_path: str) -> int:
# read the first 2048 bytes
with open(file_path, "rb") as f:
data = f.read(2048)
# if file contains non-ascii characters
if data.decode("utf-8", "ignore").isprintable() is False:
# if file contains non-ascii characters after remove EOL characters
if (
data.decode("utf-8", "ignore")
.replace("\r", "")
.replace("\n", "")
.isprintable()
is False
):
val += 50
# if first character of the byte array is a digit
if str(data[0]).isdigit() is True:
if data[0:1].decode("utf-8", "ignore").isdigit() is True:
val += 5
# if it contains the word status_code
if b"status_code" in data:
Expand Down

0 comments on commit bd836a7

Please sign in to comment.