All of lore.kernel.org
 help / color / mirror / Atom feed
* [wic][PATCH] wic: fix parsing of 'bitbake -e' output
@ 2016-12-21 14:19 Ed Bartosh
  2016-12-21 14:31 ` Maciej Borzęcki
  0 siblings, 1 reply; 4+ messages in thread
From: Ed Bartosh @ 2016-12-21 14:19 UTC (permalink / raw)
  To: openembedded-core

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>
---
 scripts/lib/wic/utils/oe/misc.py | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/scripts/lib/wic/utils/oe/misc.py b/scripts/lib/wic/utils/oe/misc.py
index fe188c9..1dbbe92 100644
--- a/scripts/lib/wic/utils/oe/misc.py
+++ b/scripts/lib/wic/utils/oe/misc.py
@@ -27,6 +27,7 @@
 """Miscellaneous functions."""
 
 import os
+import re
 from collections import defaultdict
 from distutils import spawn
 
@@ -155,14 +156,11 @@ class BitbakeVars(defaultdict):
         """
         if "=" not in line:
             return
-        try:
-            key, val = line.split("=")
-        except ValueError:
+        match = re.match("^(\w+)=(.+)", 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):
         """
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-21 17:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-21 14:19 [wic][PATCH] wic: fix parsing of 'bitbake -e' output Ed Bartosh
2016-12-21 14:31 ` Maciej Borzęcki
2016-12-21 15:05   ` [wic][PATCH v2] " Ed Bartosh
2016-12-21 17:16     ` Maciej Borzęcki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.