Skip to content

Commit

Permalink
fix regex
Browse files Browse the repository at this point in the history
  • Loading branch information
happyleavesaoc committed Oct 15, 2023
1 parent c479f89 commit d56fc62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions mgz/fast/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def parse_player(header, player_number, num_players, save):
offset = header.tell()
data = header.read()
# Skips thousands of bytes that are not easy to parse.
object_start = re.search(b'\x0b\x00.\x00\x00\x00\x02\x00\x00', data)
object_start = re.search(b'\x0b\x00.\x00\x00\x00\x02\x00\x00', data, re.DOTALL)
if not object_start:
raise RuntimeError("could not find object start")
start = object_start.end()
Expand All @@ -129,13 +129,12 @@ def parse_player(header, player_number, num_players, save):
if data[end:end + 2] == BLOCK_END:
end += 2
header.seek(offset + end)

device = 0
if save >= 37:
offset = header.tell()
data = header.read(100)
# Jump to the end of player data
player_end = re.search(b'\xff\xff\xff\xff\xff\xff\xff\xff.\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b', data)
player_end = re.search(b'\xff\xff\xff\xff\xff\xff\xff\xff.\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b', data, re.DOTALL)
if not player_end:
raise RuntimeError("could not find player end")
device = data[8]
Expand Down
2 changes: 1 addition & 1 deletion mgz/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _parse(self, stream, context, path):
read_bytes = stream.read()
candidates = []
for f in self.find:
match = re.search(f, read_bytes)
match = re.search(f, read_bytes, re.DOTALL)
if not match:
continue
candidates.append(match.end())
Expand Down

0 comments on commit d56fc62

Please sign in to comment.