Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Commit 3edf929

Browse files
committed
Enforce the same tag name rules as the docker client
1 parent 1b3d221 commit 3edf929

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

docker_registry/tags.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
store = storage.load()
2323
logger = logging.getLogger(__name__)
2424
RE_USER_AGENT = re.compile('([^\s/]+)/([^\s/]+)')
25+
RE_VALID_TAG = re.compile('^[\w][\w.-]{0,127}$')
2526

2627

2728
@app.route('/v1/repositories/<path:repository>/properties', methods=['PUT'])
@@ -182,6 +183,10 @@ def create_tag_json(user_agent):
182183
def put_tag(namespace, repository, tag):
183184
logger.debug("[put_tag] namespace={0}; repository={1}; tag={2}".format(
184185
namespace, repository, tag))
186+
if not RE_VALID_TAG.match(tag):
187+
return toolkit.api_error('Invalid tag name (must match {0})'.format(
188+
RE_VALID_TAG.pattern
189+
))
185190
data = None
186191
try:
187192
# Note(dmp): unicode patch

0 commit comments

Comments
 (0)