Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita20eb7b

Browse files
committed
[PGPRO-146] pgdata_content: checksum for truncated cfm
1 parent302db1c commita20eb7b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

‎tests/helpers/ptrack_helpers.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,8 +1709,18 @@ def pgdata_content(self, pgdata, ignore_ptrack=True, exclude_dirs=None):
17091709
file_relpath=os.path.relpath(file_fullpath,pgdata)
17101710
directory_dict['files'][file_relpath]= {'is_datafile':False}
17111711
withopen(file_fullpath,'rb')asf:
1712-
directory_dict['files'][file_relpath]['md5']=hashlib.md5(f.read()).hexdigest()
1713-
f.close()
1712+
content=f.read()
1713+
# truncate cfm's content's zero tail
1714+
iffile_relpath.endswith('.cfm'):
1715+
zero64=b"\x00"*64
1716+
l=len(content)
1717+
whilel>64:
1718+
s= (l-1)&~63
1719+
ifcontent[s:l]!=zero64[:l-s]:
1720+
break
1721+
l=s
1722+
content=content[:l]
1723+
directory_dict['files'][file_relpath]['md5']=hashlib.md5(content).hexdigest()
17141724
# directory_dict['files'][file_relpath]['md5'] = hashlib.md5(
17151725
# f = open(file_fullpath, 'rb').read()).hexdigest()
17161726

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp