Skip to content

Commit

Permalink
Update analyzer.py
Browse files Browse the repository at this point in the history
  • Loading branch information
FLOCK4H authored Mar 17, 2024
1 parent 34d84f2 commit e1ed206
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions tools/analyzer.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
# analyzer.py
import time, gc

def analyze_payload(payload):
tokens = []
i = 0
while i < len(payload):
if payload[i] == "<":
end_index = payload.find(">", i)
if end_index != -1 and ' ' not in payload[i+1:end_index]:
tokens.append(payload[i:end_index+1])
i = end_index + 1
continue
tokens.append(payload[i])
i += 1
return tokens
token_start = 0
in_token = False

for i, char in enumerate(payload):
if char == "<":
if in_token:
tokens.append(payload[token_start:i])
token_start = i
in_token = True
elif char == ">" and in_token:
tokens.append(payload[token_start:i+1])
in_token = False
token_start = i + 1
elif not in_token and (i == len(payload) - 1 or payload[i+1] == "<"):
tokens.append(payload[token_start:i+1])
token_start = i + 1

if not in_token and token_start < len(payload):
tokens.append(payload[token_start:])

return tokens

0 comments on commit e1ed206

Please sign in to comment.