[yocto] [layerindex-web][PATCH 02/10] layerindex/tools/import_layer.py: Sanitize layer name.

Paul Eggleton paul.eggleton at linux.intel.com
Mon Oct 3 15:47:20 PDT 2016


On Mon, 26 Sep 2016 14:25:30 Liam R. Howlett wrote:
> 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 at WindRiver.com>
> ---
>  layerindex/tools/import_layer.py | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/layerindex/tools/import_layer.py
> b/layerindex/tools/import_layer.py index 9b5da22..8d9e8cb 100755
> --- a/layerindex/tools/import_layer.py
> +++ b/layerindex/tools/import_layer.py
> @@ -181,6 +181,8 @@ def get_github_layerinfo(layer_url, username = None,
> password = None):
> 
> 
>  def main():
> +    valid_layer_name = re.compile('[-\w]+$')
> +
>      parser = optparse.OptionParser(
>          usage = """
>      %prog [options] <url> [name]""")
> @@ -222,6 +224,10 @@ def main():
>              if layer_name.endswith('.git'):
>                  layer_name = layer_name[:-4]
> 
> +    if not valid_layer_name.match(layer_name):
> +            logger.error('Invlaid layer name "%s" -  Layer name can only
> include letters, numbers and dashes.', layer_name) 
> +            sys.exit(1)

Typo "Invlaid", and the indenting is out here too.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre



More information about the yocto mailing list