Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

get_maintainer: remove stray punctuation when cleaning file emails

When parsing emails from .yaml files in particular, stray punctuation
such as a leading '-' can end up in the name. For example, consider a
common YAML section such as:

maintainers:
- devicetree@vger.kernel.org

This would previously be processed by get_maintainer.pl as:

- <devicetree@vger.kernel.org>

Make the logic in clean_file_emails more robust by deleting any
sub-names which consist of common single punctuation marks before
proceeding to the best-effort name extraction logic. The output is then
correct:

devicetree@vger.kernel.org

Some additional comments are added to the function to make things
clearer to future readers.

Link: https://lore.kernel.org/all/0173e76a36b3a9b4e7f324dd3a36fd4a9757f302.camel@perches.com/
Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alvin Šipraga and committed by
Linus Torvalds
2639772a 9c334eb9

+11 -7
+11 -7
scripts/get_maintainer.pl
··· 2462 2462 foreach my $email (@file_emails) { 2463 2463 $email =~ s/[\(\<\{]{0,1}([A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+)[\)\>\}]{0,1}/\<$1\>/g; 2464 2464 my ($name, $address) = parse_email($email); 2465 - if ($name eq '"[,\.]"') { 2466 - $name = ""; 2467 - } 2468 2465 2466 + # Strip quotes for easier processing, format_email will add them back 2467 + $name =~ s/^"(.*)"$/$1/; 2468 + 2469 + # Split into name-like parts and remove stray punctuation particles 2469 2470 my @nw = split(/[^\p{L}\'\,\.\+-]/, $name); 2471 + @nw = grep(!/^[\'\,\.\+-]$/, @nw); 2472 + 2473 + # Make a best effort to extract the name, and only the name, by taking 2474 + # only the last two names, or in the case of obvious initials, the last 2475 + # three names. 2470 2476 if (@nw > 2) { 2471 2477 my $first = $nw[@nw - 3]; 2472 2478 my $middle = $nw[@nw - 2]; ··· 2486 2480 } else { 2487 2481 $name = "$middle $last"; 2488 2482 } 2483 + } else { 2484 + $name = "@nw"; 2489 2485 } 2490 2486 2491 2487 if (substr($name, -1) =~ /[,\.]/) { 2492 2488 $name = substr($name, 0, length($name) - 1); 2493 - } elsif (substr($name, -2) =~ /[,\.]"/) { 2494 - $name = substr($name, 0, length($name) - 2) . '"'; 2495 2489 } 2496 2490 2497 2491 if (substr($name, 0, 1) =~ /[,\.]/) { 2498 2492 $name = substr($name, 1, length($name) - 1); 2499 - } elsif (substr($name, 0, 2) =~ /"[,\.]/) { 2500 - $name = '"' . substr($name, 2, length($name) - 2); 2501 2493 } 2502 2494 2503 2495 my $fmt_email = format_email($name, $address, $email_usename);