Blacklist http(s): from being parsed as a git footer
It's unlikely that anyone would ever intend to have a git trailer
whose key is "http", but since URLs are often long, it is rather
likely that someone would put a URL on a line all by itself. When
that happens, don't accidentally interpret it as a footer.
R=iannucci, tandrii
Bug: 766234
Change-Id: I3101119c4e49e20339487618cc1719452b026d90
Reviewed-on: https://chromium-review.googlesource.com/849484
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
diff --git a/git_footers.py b/git_footers.py
index 3f12d17..92c7dab 100755
--- a/git_footers.py
+++ b/git_footers.py
@@ -15,6 +15,7 @@
FOOTER_PATTERN = re.compile(r'^\s*([\w-]+): *(.*)$')
CHROME_COMMIT_POSITION_PATTERN = re.compile(r'^([\w/\-\.]+)@{#(\d+)}$')
+FOOTER_KEY_BLACKLIST = set(['http', 'https'])
def normalize_name(header):
@@ -24,10 +25,9 @@
def parse_footer(line):
"""Returns footer's (key, value) if footer is valid, else None."""
match = FOOTER_PATTERN.match(line)
- if match:
+ if match and match.group(1) not in FOOTER_KEY_BLACKLIST:
return (match.group(1), match.group(2))
- else:
- return None
+ return None
def parse_footers(message):