Skip to content

Commit

Permalink
Update pycatfile.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski committed Feb 6, 2025
1 parent 3e9ec15 commit 212514a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pycatfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, uncompress=True, skipcheck
fjsonsize = int(HeaderOut[27], 16)
fjsoncontent = {}
fprejsoncontent = fp.read(fjsonsize).decode("UTF-8")
if(len(fjsoncontent) > 0):
if(fjsonsize > 0):
try:
fjsoncontent = json.loads(base64.b64decode(fprejsoncontent).decode("UTF-8"))
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
Expand Down Expand Up @@ -2239,7 +2239,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
pass
fjsoncontent = {}
fprejsoncontent = fp.read(fjsonsize).decode("UTF-8")
if(len(fjsoncontent) > 0):
if(fjsonsize > 0):
try:
fjsoncontent = json.loads(base64.b64decode(fprejsoncontent).decode("UTF-8"))
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
Expand Down Expand Up @@ -3398,7 +3398,7 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], filecontent="",
fprejsoncontent = {'testing': "test"}
if(len(fprejsoncontent) > 0):
try:
fjsoncontent = base64.b64encode(json.dumps(fprejsoncontent).encode("UTF-8"))
fjsoncontent = base64.b64encode(json.dumps(fprejsoncontent, separators=(',', ':')).encode("UTF-8"))
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
try:
fjsoncontent = json.dumps(fprejsoncontent.decode("UTF-8"))
Expand Down

0 comments on commit 212514a

Please sign in to comment.