Make sure to decode manifests into utf-8 when necessary
This fixes a decoding error
This commit is contained in:
parent
6cc7102ec8
commit
48e584905a
15 changed files with 268 additions and 32 deletions
|
|
@ -281,12 +281,12 @@ class V2Protocol(RegistryProtocol):
|
|||
if images[-1].config:
|
||||
config['config'] = images[-1].config
|
||||
|
||||
config_json = json.dumps(config)
|
||||
config_json = json.dumps(config, ensure_ascii=options.ensure_ascii)
|
||||
schema2_config = DockerSchema2Config(config_json)
|
||||
builder.set_config(schema2_config)
|
||||
|
||||
blobs[schema2_config.digest] = schema2_config.bytes
|
||||
return builder.build()
|
||||
blobs[schema2_config.digest] = schema2_config.bytes.encode('utf-8')
|
||||
return builder.build(ensure_ascii=options.ensure_ascii)
|
||||
|
||||
def build_schema1(self, namespace, repo_name, tag_name, images, blobs, options):
|
||||
builder = DockerSchema1ManifestBuilder(namespace, repo_name, tag_name)
|
||||
|
|
@ -311,10 +311,14 @@ class V2Protocol(RegistryProtocol):
|
|||
if image.created is not None:
|
||||
layer_dict['created'] = image.created
|
||||
|
||||
builder.add_layer(checksum, json.dumps(layer_dict))
|
||||
builder.add_layer(checksum, json.dumps(layer_dict, ensure_ascii=options.ensure_ascii))
|
||||
|
||||
# Build the manifest.
|
||||
return builder.build(self.jwk)
|
||||
built = builder.build(self.jwk, ensure_ascii=options.ensure_ascii)
|
||||
|
||||
# Validate it before we send it.
|
||||
DockerSchema1Manifest(built.bytes)
|
||||
return built
|
||||
|
||||
def push(self, session, namespace, repo_name, tag_names, images, credentials=None,
|
||||
expected_failure=None, options=None):
|
||||
|
|
@ -368,7 +372,7 @@ class V2Protocol(RegistryProtocol):
|
|||
tag_or_digest = tag_name if not options.push_by_manifest_digest else manifest.digest
|
||||
self.conduct(session, 'PUT',
|
||||
'/v2/%s/manifests/%s' % (self.repo_name(namespace, repo_name), tag_or_digest),
|
||||
data=manifest.bytes,
|
||||
data=manifest.bytes.encode('utf-8'),
|
||||
expected_status=(put_code, expected_failure, V2ProtocolSteps.PUT_MANIFEST),
|
||||
headers=manifest_headers)
|
||||
|
||||
|
|
|
|||
Reference in a new issue