Skip to content

Commit

Permalink
Update pyarchivefile.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski committed Feb 13, 2025
1 parent 8a211bb commit 9c21864
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pyarchivefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3390,12 +3390,9 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], jsondata={}, fi
fjsontype = "json"
if(len(jsondata) > 0):
try:
fjsoncontent = base64.b64encode(json.dumps(jsondata, separators=(',', ':')).encode("UTF-8"))
fjsoncontent = json.dumps(jsondata, separators=(',', ':')).encode("UTF-8")
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
try:
fjsoncontent = json.dumps(jsondata.decode("UTF-8"))
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
fjsoncontent = "".encode("UTF-8")
fjsoncontent = "".encode("UTF-8")
else:
fjsoncontent = "".encode("UTF-8")
fjsonsize = format(len(fjsoncontent), 'x').lower()
Expand Down Expand Up @@ -7291,10 +7288,10 @@ def ArchiveFileValidate(infile, fmttype="auto", formatspecs=__file_format_multi_
outfprejsoncontent = fp.read(outfjsonsize).decode("UTF-8")
if(outfjsonsize > 0):
try:
outfjsoncontent = json.loads(base64.b64decode(outfprejsoncontent).decode("UTF-8"))
outfjsoncontent = json.loads(base64.b64decode(outfprejsoncontent.encode("UTF-8")).decode("UTF-8"))
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
try:
outfjsoncontent = json.loads(outfprejsoncontent.decode("UTF-8"))
outfjsoncontent = json.loads(outfprejsoncontent)
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
outfprejsoncontent = ""
outfjsoncontent = {}
Expand Down Expand Up @@ -7723,10 +7720,10 @@ def ArchiveFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=
outfprejsoncontent = fp.read(outfjsonsize).decode("UTF-8")
if(outfjsonsize > 0):
try:
outfjsoncontent = json.loads(base64.b64decode(outfprejsoncontent).decode("UTF-8"))
outfjsoncontent = json.loads(base64.b64decode(outfprejsoncontent.encode("UTF-8")).decode("UTF-8"))
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
try:
outfjsoncontent = json.loads(outfprejsoncontent.decode("UTF-8"))
outfjsoncontent = json.loads(outfprejsoncontent)
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
outfprejsoncontent = ""
outfjsoncontent = {}
Expand Down

0 comments on commit 9c21864

Please sign in to comment.