From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [wic][PATCH] wic: fix parsing of 'bitbake -e' output
Date: Wed, 21 Dec 2016 16:19:57 +0200 [thread overview]
Message-ID: <1482329997-20677-1-git-send-email-ed.bartosh@linux.intel.com> (raw)
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
next reply other threads:[~2016-12-21 14:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-21 14:19 Ed Bartosh [this message]
2016-12-21 14:31 ` [wic][PATCH] wic: fix parsing of 'bitbake -e' output Maciej Borzęcki
2016-12-21 15:05 ` [wic][PATCH v2] " Ed Bartosh
2016-12-21 17:16 ` Maciej Borzęcki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1482329997-20677-1-git-send-email-ed.bartosh@linux.intel.com \
--to=ed.bartosh@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.