lint: avoid false positives with URLs at start of line in body

When the message body's last line starts with a URL, lint thought this
was a footer line. This change blacklists URLs using the same regexp
as the Gerrit commit-msg hook, by matching ^[a-ZA-Z0-9-]:// (i.e. a
footer field name directly followed by two slashes)

Change-Id: I061bee679e7ec807fa0d7c233fbbf432faa268c0
diff --git a/lint/lint.go b/lint/lint.go
index 485c267..b99ebe9 100644
--- a/lint/lint.go
+++ b/lint/lint.go
@@ -158,6 +158,7 @@
 var fixesIssueRegexp = regexp.MustCompile("(?i)^fixes issue [0-9]{3,}[.]?$")
 var issueRegexp = regexp.MustCompile("(?i)issue [0-9]{3,}")
 var footerRegexp = regexp.MustCompile("^[A-Za-z0-9-]+:")
+var urlAtStartOfLineRegexp = regexp.MustCompile("^[A-Za-z0-9-]+://")
 
 func (l *linter) checkMessage(commitmsg []string, offset int) {
 	warn := func(line int, message string) {
@@ -182,13 +183,16 @@
 	}
 
 	// Note: don't check subject line
+	// Parsing for footer lines in JGit can be found at:
+	// https://eclipse.googlesource.com/jgit/jgit/+/master/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java#498
 	for i, inFooter := len(commitmsg)-1, true; i >= 1; i-- {
 		if len(commitmsg[i]) == 0 {
 			inFooter = false
 			continue
 		}
-		if !footerRegexp.MatchString(commitmsg[i]) {
+		if !footerRegexp.MatchString(commitmsg[i]) || urlAtStartOfLineRegexp.MatchString(commitmsg[i]) {
 			if inFooter {
+				// Note: we assume there's always a footer (at a minimum with the Change-Id)
 				warn(i+1, "Footer lines should be separated from message body by a blank line.")
 			}
 			break
diff --git a/lint/lint_test.go b/lint/lint_test.go
index 16a050e..8dc4378 100644
--- a/lint/lint_test.go
+++ b/lint/lint_test.go
@@ -203,6 +203,22 @@
 			message: []string{
 				"Subject line",
 				"",
+				"URI in footer should be reported",
+				"",
+				"http://example.com",
+				"Change-Id: blah",
+			},
+			warnings: []gerrit.Comment{
+				gerrit.Comment{
+					Line:    5,
+					Message: "[warning] Footer lines should be separated from message body by a blank line.",
+				},
+			},
+		},
+		{
+			message: []string{
+				"Subject line",
+				"",
 				"Bug: issue 8403",
 				"",
 				"Change-Id: blah",
@@ -214,6 +230,17 @@
 				},
 			},
 		},
+		{
+			message: []string{
+				"Subject line",
+				"",
+				"URI in message body shouldn't be seen as a footer",
+				"http://example.com",
+				"",
+				"Change-Id: blah",
+			},
+			// No warnings
+		},
 	}
 
 	for _, test := range tests {