]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic: fix parsing of 'bitbake -e' output
authorEd Bartosh <ed.bartosh@linux.intel.com>
Wed, 21 Dec 2016 15:05:11 +0000 (17:05 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 16 Jan 2017 18:01:52 +0000 (18:01 +0000)
Current parsing code can wrongly interpret arbitrary lines
that are of 'key=value' format as legitimate bitbake variables.

Implemented more strict parsing of key=value pairs using
regular expressions.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
scripts/lib/wic/utils/oe/misc.py

index fe188c9d26dfdc715fb4eab1006ce416e4f5490e..2a2fcc94fbb56cc7db496e67f4ba76f7b76867ea 100644 (file)
@@ -27,6 +27,7 @@
 """Miscellaneous functions."""
 
 import os
+import re
 from collections import defaultdict
 from distutils import spawn
 
@@ -148,21 +149,18 @@ class BitbakeVars(defaultdict):
         self.default_image = None
         self.vars_dir = None
 
-    def _parse_line(self, line, image):
+    def _parse_line(self, line, image, matcher=re.compile(r"^(\w+)=(.+)")):
         """
         Parse one line from bitbake -e output or from .env file.
         Put result key-value pair into the storage.
         """
         if "=" not in line:
             return
-        try:
-            key, val = line.split("=")
-        except ValueError:
+        match = matcher.match(line)
+        if not match:
             return
-        key = key.strip()
-        val = val.strip()
-        if key.replace('_', '').isalnum():
-            self[image][key] = val.strip('"')
+        key, val = match.groups()
+        self[image][key] = val.strip('"')
 
     def get_var(self, var, image=None):
         """