On Wed, Dec 21, 2016 at 3:19 PM, Ed Bartosh <ed.bart...@linux.intel.com> wrote: > 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.bart...@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)
match = re.match(r"^(\w+)=(.+)", line) I don't remember if regexps are cached when compiled in re.match(), but perhaps it would be better to `re.compile(r"^(\w+)=(.+)")` in BitbakeVars.__init__() and just use a cached object here? > + 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 > -- Maciej Borzecki RnDity -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core