Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #29 from adelosa/#27-warn-when-invalid-block-chars
Browse files Browse the repository at this point in the history
added log warning if 1014 block character is unexpected
  • Loading branch information
adelosa authored Aug 10, 2016
2 parents e88dbbe + 3de9255 commit 5e1bb53
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mciutil/mciutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ def unblock(blocked_data):
:param blocked_data: String containing 1014 blocked data or file
:return: list of records in file
"""

block_warning_triggered = False
file_pointer = 0
unblock_data = []

while file_pointer <= len(blocked_data):
unblock_data.append(blocked_data[file_pointer:file_pointer+1012])
LOGGER.debug("Block chars [%s]", blocked_data[file_pointer+1012:file_pointer+1014])
if not block_warning_triggered and (
blocked_data[file_pointer+1012:file_pointer+1014] not in (b(''), b("\x40\x40"))):
LOGGER.warn("File may not be in 1014 blocked format - found unusual EOB marker %s, usually x'40'x'40'\n"
"Consider using --no1014blocking option if file is VBS format",
blocked_data[file_pointer+1012:file_pointer+1014])
block_warning_triggered = True
file_pointer += 1014

return vbs_unpack(b("").join(unblock_data))
Expand Down

0 comments on commit 5e1bb53

Please sign in to comment.