mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
layerindex/tools/import_layer.py: Sanitize layer name
Django will produce a cryptic error message if layers are added with invalid names. Sanitize the layer names when trying to add them. Signed-off-by: Liam R. Howlett <Liam.Howlett@WindRiver.com>
This commit is contained in:
parent
aaddb1c9a5
commit
4bbc210d34
|
@ -181,6 +181,8 @@ def get_github_layerinfo(layer_url, username = None, password = None):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
valid_layer_name = re.compile('[-\w]+$')
|
||||||
|
|
||||||
parser = optparse.OptionParser(
|
parser = optparse.OptionParser(
|
||||||
usage = """
|
usage = """
|
||||||
%prog [options] <url> [name]""")
|
%prog [options] <url> [name]""")
|
||||||
|
@ -222,6 +224,10 @@ def main():
|
||||||
if layer_name.endswith('.git'):
|
if layer_name.endswith('.git'):
|
||||||
layer_name = layer_name[:-4]
|
layer_name = layer_name[:-4]
|
||||||
|
|
||||||
|
if not valid_layer_name.match(layer_name):
|
||||||
|
logger.error('Invalid layer name "%s" - Layer name can only include letters, numbers and dashes.', layer_name)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if options.github_auth:
|
if options.github_auth:
|
||||||
if not ':' in options.github_auth:
|
if not ':' in options.github_auth:
|
||||||
logger.error('--github-auth value must be specified as username:password')
|
logger.error('--github-auth value must be specified as username:password')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user