check syntax of description field in logtags files

EventLog.java checks that the field descriptions are bracketed by
parens, so we should to in order to avoid a runtime error from a
logtag entry with bad syntax.

Bug: 3381309
Change-Id: I1d4cbb190da6b81ec0b1f1de9b5bc3f3394d7ec1
This commit is contained in:
Doug Zongker 2011-01-23 12:57:19 -08:00
parent 7838fa6e9c
commit e128cbda07
1 changed files with 8 additions and 0 deletions

View File

@ -90,6 +90,14 @@ class TagFile(object):
else:
description = None
if description:
# EventLog.java checks that the description field is
# surrounded by parens, so we should too (to avoid a runtime
# crash from badly-formatted descriptions).
if not re.match(r"\(.*\)\s*$", description):
self.AddError("tag \"%s\" has unparseable description" % (tagname,))
continue
self.tags.append(Tag(tag, tagname, description,
self.filename, self.linenum))
except (IOError, OSError), e: