Skip to contentSkip to conversation

checkpatch: fix missing whitespace in formatted email

PATCH In review Dwaipayan Ray 2 participants 3 messages Oct 13, 2020 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 checkpatch: fix missing whitespace in formatted email

Commit 0c01921e56f9 ("checkpatch: add new warnings to author signoff checks.") introduced new checks for author sign off. The format_email procedure was modified to add comment blocks to the formatted email. But no space was added between the email address and mail comment.

This causes wrong email formatting in cases where the email is in the form "[email protected] (Comment block)". The space between the address and comment block is removed, which causes incorrect parsing of the formatted email.

An evaluation on checkpatch brought up this case. For example, on commit 1129d31b55d5 ("ima: Fix ima digest hash table key calculation"), the following warning was reported:

WARNING:BAD_SIGN_OFF: email address '[email protected] (big endian system concerns)' might be better as '[email protected](big endian system concerns)'

Add a single space in between the address and comment when the extracted comment is not empty.

Fixes 0c01921e56f9 ("checkpatch: add new warnings to author signoff checks.")
---
 scripts/checkpatch.pl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +3 -1
index fab38b493cef..f1a4e61917eb 100755
@@ -1221,7 +1221,9 @@ sub format_email {
 	} else {
 		$formatted_email = "$name$name_comment <$address>";
 	}
-	$formatted_email .= "$comment";
+	if ("$comment" ne "") {
+		$formatted_email .= " $comment";
+	}
 	return $formatted_email;
 }
 
Signature · 6 lines
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
maintainer
#1 lore raw
Quoted 10 lines · Dwaipayan Ray

Commit 0c01921e56f9 ("checkpatch: add new warnings to author signoff checks.") introduced new checks for author sign off. The format_email procedure was modified to add comment blocks to the formatted email. But no space was added between the email address and mail comment.

This causes wrong email formatting in cases where the email is in the form "[email protected] (Comment block)". The space between the address and comment block is removed, which causes incorrect parsing of the formatted email.

Quoted 7 lines

An evaluation on checkpatch brought up this case. For example, on commit 1129d31b55d5 ("ima: Fix ima digest hash table key calculation"), the following warning was reported:

WARNING:BAD_SIGN_OFF: email address '[email protected] (big endian system concerns)' might be better as '[email protected](big endian system concerns)'

Strictly, a comment or multiple comments can exist in any part of an email

"John (Jon) Smith (Smitty) <[email protected]> (tld is the best tld)

Quoted 2 lines

Add a single space in between the address and comment when the extracted comment is not empty.

So after the address is not necessarily the best
location for a comment.

#2 lore raw
Quoted 23 lines · Joe Perches
Quoted 10 lines · Dwaipayan Ray

Commit 0c01921e56f9 ("checkpatch: add new warnings to author signoff checks.") introduced new checks for author sign off. The format_email procedure was modified to add comment blocks to the formatted email. But no space was added between the email address and mail comment.

This causes wrong email formatting in cases where the email is in the form "[email protected] (Comment block)". The space between the address and comment block is removed, which causes incorrect parsing of the formatted email.

Quoted 7 lines

An evaluation on checkpatch brought up this case. For example, on commit 1129d31b55d5 ("ima: Fix ima digest hash table key calculation"), the following warning was reported:

WARNING:BAD_SIGN_OFF: email address '[email protected] (big endian system concerns)' might be better as '[email protected](big endian system concerns)'

Strictly, a comment or multiple comments can exist in any part of an email

Quoted 9 lines

"John (Jon) Smith (Smitty) <[email protected]> (tld is the best tld)

Quoted 2 lines

Add a single space in between the address and comment when the extracted comment is not empty.

So after the address is not necessarily the best
location for a comment.

Yes I agree and in cases like that the check works perfectly. But now consider the case when the name is empty:

Like:
[email protected] (tld is the best tld).

In this case when the formatted email is generated, we have
the following: "[email protected](tld is the best tld)".
If this email is parsed again, the entire part is parsed as the email address, which causes a mismatch later on.

It is for only this case that an extra white space is needed for the parsing, probably because of how the comment is captured, for emails with empty names:
$formatted_email =~ /(\S+\@\S+)(.*)$/
So it depends on the whitespace after address to demarcate the comment.

Some more examples of what I intend to solve:
'<[email protected]> [5.3+]' '<[email protected]> # v5.7+' '[email protected] (big endian system concerns)'

Thanks,
Dwaipayan.