diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-04-09 05:29:31 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-04-09 05:29:31 +0000 |
commit | 1a0b941b2c80fa569b31a578cbd933b6c0031d09 (patch) | |
tree | 38291f96d882eb6687bab3c691beb81941318587 /pym/portage/elog/messages.py | |
parent | 8ec5af26b02cdc3613f2545e4c0be4eee158352e (diff) | |
download | portage-1a0b941b2c80fa569b31a578cbd933b6c0031d09.tar.gz portage-1a0b941b2c80fa569b31a578cbd933b6c0031d09.tar.bz2 portage-1a0b941b2c80fa569b31a578cbd933b6c0031d09.zip |
Handle issues with newlines in elog messages that can trigger an unhandled
ValueError to be raised from a split() call inside collect_ebuild_messages():
* Use \0 to delimit messages, so that that elog messages containing newlines
are handled correctly.
* Handle a potential ValueError when splitting the message type.
svn path=/main/trunk/; revision=9763
Diffstat (limited to 'pym/portage/elog/messages.py')
-rw-r--r-- | pym/portage/elog/messages.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/pym/portage/elog/messages.py b/pym/portage/elog/messages.py index bca63554e..341a61d1f 100644 --- a/pym/portage/elog/messages.py +++ b/pym/portage/elog/messages.py @@ -25,16 +25,24 @@ def collect_ebuild_messages(path): mylogfiles.reverse() logentries = {} for msgfunction in mylogfiles: + filename = os.path.join(path, msgfunction) if msgfunction not in EBUILD_PHASES: - writemsg("!!! can't process invalid log file: %s\n" % f, + writemsg("!!! can't process invalid log file: %s\n" % filename, noiselevel=-1) continue if not msgfunction in logentries: logentries[msgfunction] = [] lastmsgtype = None msgcontent = [] - for l in open(os.path.join(path, msgfunction), "r").readlines(): - msgtype, msg = l.split(" ", 1) + for l in open(filename, "r").read().split("\0"): + if not l: + continue + try: + msgtype, msg = l.split(" ", 1) + except ValueError: + writemsg("!!! malformed entry in " + \ + "log file: '%s'\n" % filename, noiselevel=-1) + continue if lastmsgtype is None: lastmsgtype = msgtype if msgtype == lastmsgtype: |