summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfengbaolong <fengbaolong@hotmail.com>2020-04-28 16:37:02 +0800
committerfengbaolong <fengbaolong@hotmail.com>2020-04-28 20:01:59 +0800
commita07b5ee16c1368a5873cfa08e5f407cbe7d275f5 (patch)
tree5abfcc0bd1e3c6ee58fb05c0a0c303b6207d182a
parent9a24df5cdd03c679dc929735e4766e19ff1c2bdb (diff)
downloaddocker-py-a07b5ee16c1368a5873cfa08e5f407cbe7d275f5.tar.gz
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>
-rw-r--r--docker/utils/build.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/docker/utils/build.py b/docker/utils/build.py
index 4fa5751..5787cab 100644
--- a/docker/utils/build.py
+++ b/docker/utils/build.py
@@ -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)