All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Flag spam header (X-Spam-Report) to prevent spurious warnings
@ 2017-03-21 16:30 John 'Warthog9' Hawley (VMware)
  2017-03-21 18:31 ` Joe Perches
  0 siblings, 1 reply; 8+ messages in thread
From: John 'Warthog9' Hawley (VMware) @ 2017-03-21 16:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: Joe Perches, Andy Whitcroft, Darren Hart (VMware),
	John 'Warthog9' Hawley (VMware)

Spamassassin sticks a long (~79 character) long string after a
line that has a single space in it. The line with space causes
checkpatch to erroniously think that it's in the content body, as
opposed to headers and thus flag a mail header as an unwrapped long
comment line.

This flags when X-Spam-Report is found, till an e-mail
body indicator (blank line, /^[/n/r]*/) is found, blocking setting
$in_commit_log.  When found, unsets itself allowing the rest of
the detection to function normally.

Reported-by: Darren Hart (VMware) <dvhart@infradead.org>
Signed-off-by: John 'Warthog9' Hawley (VMware) <warthog9@eaglescrag.net>
---
 scripts/checkpatch.pl | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index baa3c7b..d2ce89a 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2134,6 +2134,7 @@ sub process {
 	my $signoff = 0;
 	my $is_patch = 0;
 	my $in_header_lines = $file ? 0 : 1;
+	my $found_spam_header = 0;
 	my $in_commit_log = 0;		#Scanning lines before patch
 	my $has_commit_log = 0;		#Encountered lines before patch
 	my $commit_log_possible_stack_dump = 0;
@@ -2279,6 +2280,12 @@ sub process {
 
 		my $rawline = $rawlines[$linenr - 1];
 
+#if we encounter a spamassassin mail header, mark it
+		if ($in_header_lines == 1 && $line =~ /^X-Spam-Report:/) {
+			#mail header found, this needs to be flagged
+			$found_spam_header = 1;
+		}
+
 #extract the line range in the file after the patch is applied
 		if (!$in_commit_log &&
 		    $line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
@@ -2627,9 +2634,15 @@ sub process {
 
 # Check if it's the start of a commit log
 # (not a header line and we haven't seen the patch filename)
+		if ($in_header_lines && $found_spam_header && $line =~ /^[\n\r]*$/) {
+			# we are now past the header info that could be confusing
+			$found_spam_header = 0;
+		}
+
 		if ($in_header_lines && $realfile =~ /^$/ &&
 		    !($rawline =~ /^\s+\S/ ||
-		      $rawline =~ /^(commit\b|from\b|[\w-]+:).*$/i)) {
+		      $rawline =~ /^(commit\b|from\b|[\w-]+:).*$/i) &&
+		    !$found_spam_header) {
 			$in_header_lines = 0;
 			$in_commit_log = 1;
 			$has_commit_log = 1;
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-03-24 20:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-21 16:30 [PATCH] checkpatch: Flag spam header (X-Spam-Report) to prevent spurious warnings John 'Warthog9' Hawley (VMware)
2017-03-21 18:31 ` Joe Perches
2017-03-22 15:25   ` Darren Hart
2017-03-22 18:17     ` Joe Perches
2017-03-23  6:01       ` Darren Hart
2017-03-23  6:07         ` Joe Perches
2017-03-24 20:14   ` John 'Warthog9' Hawley
2017-03-24 20:19     ` John 'Warthog9' Hawley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.