Commit b08ba657 authored by Aaron Gable's avatar Aaron Gable Committed by Commit Bot

git_footer: be more resilient to malformed footers

Since split_footers became more resilient to malformed
footers and started returning the entire last paragraph,
instead of just the last paragraph iff it was entirely
well-formed, other functions like remove_footer need to
make sure they handle the case where not every line of
the footer paragraph can be parsed.

R=iannucci@chromium.org

Bug: 740601
Change-Id: I75c6c626d96942181f453abeee896ee92d14b20b
Reviewed-on: https://chromium-review.googlesource.com/565779Reviewed-by: 's avatarRobbie Iannucci <iannucci@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
parent 9d842bab
......@@ -146,8 +146,15 @@ def remove_footer(message, key):
top_lines, footer_lines, _ = split_footers(message)
if not footer_lines:
return message
new_footer_lines = [
l for l in footer_lines if normalize_name(parse_footer(l)[0]) != key]
new_footer_lines = []
for line in footer_lines:
try:
f = normalize_name(parse_footer(line)[0])
if f != key:
new_footer_lines.append(line)
except TypeError:
# If the footer doesn't parse (i.e. is malformed), just let it carry over.
new_footer_lines.append(line)
return '\n'.join(top_lines + new_footer_lines)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment