fix docker build error when dockerfile contains unicode character.

if dockerfile contains unicode character,len(contents) will return character length,this length will less than len(contents_encoded) length,so contants data will be truncated.

Signed-off-by: fengbaolong <fengbaolong@hotmail.com>
This commit is contained in:
fengbaolong 2020-04-28 16:37:02 +08:00 committed by aiordache
parent d0467badfb
commit 9f5e35f5fe
1 changed files with 3 additions and 2 deletions

View File

@ -105,8 +105,9 @@ def create_archive(root, files=None, fileobj=None, gzip=False,
for name, contents in extra_files:
info = tarfile.TarInfo(name)
info.size = len(contents)
t.addfile(info, io.BytesIO(contents.encode('utf-8')))
contents_encoded = contents.encode('utf-8')
info.size = len(contents_encoded)
t.addfile(info, io.BytesIO(contents_encoded))
t.close()
fileobj.seek(0)