diff options
Diffstat (limited to 'scripts/get_maintainer.pl')
-rwxr-xr-x | scripts/get_maintainer.pl | 145 |
1 files changed, 129 insertions, 16 deletions
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index 22c7f4e740f1..7cf4309932f3 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl | |||
@@ -55,6 +55,10 @@ foreach my $chief (@penguin_chief) { | |||
55 | } | 55 | } |
56 | my $penguin_chiefs = "\(" . join("|",@penguin_chief_names) . "\)"; | 56 | my $penguin_chiefs = "\(" . join("|",@penguin_chief_names) . "\)"; |
57 | 57 | ||
58 | # rfc822 - preloaded methods go here. | ||
59 | my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])"; | ||
60 | my $rfc822_char = '[\\000-\\177]'; | ||
61 | |||
58 | if (!GetOptions( | 62 | if (!GetOptions( |
59 | 'email!' => \$email, | 63 | 'email!' => \$email, |
60 | 'git!' => \$email_git, | 64 | 'git!' => \$email_git, |
@@ -392,18 +396,7 @@ sub add_categories { | |||
392 | } | 396 | } |
393 | } elsif ($ptype eq "M") { | 397 | } elsif ($ptype eq "M") { |
394 | if ($email_maintainer) { | 398 | if ($email_maintainer) { |
395 | if ($index >= 0) { | 399 | push_email_addresses($pvalue); |
396 | my $tv = $typevalue[$index - 1]; | ||
397 | if ($tv =~ m/^(\C):\s*(.*)/) { | ||
398 | if ($1 eq "P" && $email_usename) { | ||
399 | push(@email_to, format_email($2, $pvalue)); | ||
400 | } else { | ||
401 | push(@email_to, $pvalue); | ||
402 | } | ||
403 | } | ||
404 | } else { | ||
405 | push(@email_to, $pvalue); | ||
406 | } | ||
407 | } | 400 | } |
408 | } elsif ($ptype eq "T") { | 401 | } elsif ($ptype eq "T") { |
409 | push(@scm, $pvalue); | 402 | push(@scm, $pvalue); |
@@ -421,6 +414,36 @@ sub add_categories { | |||
421 | } | 414 | } |
422 | } | 415 | } |
423 | 416 | ||
417 | sub push_email_address { | ||
418 | my ($email_address) = @_; | ||
419 | |||
420 | my $email_name = ""; | ||
421 | if ($email_address =~ m/([^<]+)<(.*\@.*)>$/) { | ||
422 | $email_name = $1; | ||
423 | $email_address = $2; | ||
424 | } | ||
425 | |||
426 | if ($email_usename && $email_name) { | ||
427 | push(@email_to, format_email($email_name, $email_address)); | ||
428 | } else { | ||
429 | push(@email_to, $email_address); | ||
430 | } | ||
431 | } | ||
432 | |||
433 | sub push_email_addresses { | ||
434 | my ($address) = @_; | ||
435 | |||
436 | my @address_list = (); | ||
437 | |||
438 | if (@address_list = rfc822_validlist($address)) { | ||
439 | my $array_count = shift(@address_list); | ||
440 | while (my $entry = shift(@address_list)) { | ||
441 | push_email_address($entry); | ||
442 | } | ||
443 | } | ||
444 | |||
445 | } | ||
446 | |||
424 | sub which { | 447 | sub which { |
425 | my ($bin) = @_; | 448 | my ($bin) = @_; |
426 | 449 | ||
@@ -480,10 +503,6 @@ sub recent_git_signoffs { | |||
480 | if ($line =~ m/(.+)<(.+)>/) { | 503 | if ($line =~ m/(.+)<(.+)>/) { |
481 | my $git_name = $1; | 504 | my $git_name = $1; |
482 | my $git_addr = $2; | 505 | my $git_addr = $2; |
483 | $git_name =~ tr/^\"//; | ||
484 | $git_name =~ tr/^\\s*//; | ||
485 | $git_name =~ tr/\"$//; | ||
486 | $git_name =~ tr/\\s*$//; | ||
487 | if ($email_usename) { | 506 | if ($email_usename) { |
488 | push(@email_to, format_email($git_name, $git_addr)); | 507 | push(@email_to, format_email($git_name, $git_addr)); |
489 | } else { | 508 | } else { |
@@ -527,3 +546,97 @@ sub output { | |||
527 | print("\n"); | 546 | print("\n"); |
528 | } | 547 | } |
529 | } | 548 | } |
549 | |||
550 | my $rfc822re; | ||
551 | |||
552 | sub make_rfc822re { | ||
553 | # Basic lexical tokens are specials, domain_literal, quoted_string, atom, and | ||
554 | # comment. We must allow for rfc822_lwsp (or comments) after each of these. | ||
555 | # This regexp will only work on addresses which have had comments stripped | ||
556 | # and replaced with rfc822_lwsp. | ||
557 | |||
558 | my $specials = '()<>@,;:\\\\".\\[\\]'; | ||
559 | my $controls = '\\000-\\037\\177'; | ||
560 | |||
561 | my $dtext = "[^\\[\\]\\r\\\\]"; | ||
562 | my $domain_literal = "\\[(?:$dtext|\\\\.)*\\]$rfc822_lwsp*"; | ||
563 | |||
564 | my $quoted_string = "\"(?:[^\\\"\\r\\\\]|\\\\.|$rfc822_lwsp)*\"$rfc822_lwsp*"; | ||
565 | |||
566 | # Use zero-width assertion to spot the limit of an atom. A simple | ||
567 | # $rfc822_lwsp* causes the regexp engine to hang occasionally. | ||
568 | my $atom = "[^$specials $controls]+(?:$rfc822_lwsp+|\\Z|(?=[\\[\"$specials]))"; | ||
569 | my $word = "(?:$atom|$quoted_string)"; | ||
570 | my $localpart = "$word(?:\\.$rfc822_lwsp*$word)*"; | ||
571 | |||
572 | my $sub_domain = "(?:$atom|$domain_literal)"; | ||
573 | my $domain = "$sub_domain(?:\\.$rfc822_lwsp*$sub_domain)*"; | ||
574 | |||
575 | my $addr_spec = "$localpart\@$rfc822_lwsp*$domain"; | ||
576 | |||
577 | my $phrase = "$word*"; | ||
578 | my $route = "(?:\@$domain(?:,\@$rfc822_lwsp*$domain)*:$rfc822_lwsp*)"; | ||
579 | my $route_addr = "\\<$rfc822_lwsp*$route?$addr_spec\\>$rfc822_lwsp*"; | ||
580 | my $mailbox = "(?:$addr_spec|$phrase$route_addr)"; | ||
581 | |||
582 | my $group = "$phrase:$rfc822_lwsp*(?:$mailbox(?:,\\s*$mailbox)*)?;\\s*"; | ||
583 | my $address = "(?:$mailbox|$group)"; | ||
584 | |||
585 | return "$rfc822_lwsp*$address"; | ||
586 | } | ||
587 | |||
588 | sub rfc822_strip_comments { | ||
589 | my $s = shift; | ||
590 | # Recursively remove comments, and replace with a single space. The simpler | ||
591 | # regexps in the Email Addressing FAQ are imperfect - they will miss escaped | ||
592 | # chars in atoms, for example. | ||
593 | |||
594 | while ($s =~ s/^((?:[^"\\]|\\.)* | ||
595 | (?:"(?:[^"\\]|\\.)*"(?:[^"\\]|\\.)*)*) | ||
596 | \((?:[^()\\]|\\.)*\)/$1 /osx) {} | ||
597 | return $s; | ||
598 | } | ||
599 | |||
600 | # valid: returns true if the parameter is an RFC822 valid address | ||
601 | # | ||
602 | sub rfc822_valid ($) { | ||
603 | my $s = rfc822_strip_comments(shift); | ||
604 | |||
605 | if (!$rfc822re) { | ||
606 | $rfc822re = make_rfc822re(); | ||
607 | } | ||
608 | |||
609 | return $s =~ m/^$rfc822re$/so && $s =~ m/^$rfc822_char*$/; | ||
610 | } | ||
611 | |||
612 | # validlist: In scalar context, returns true if the parameter is an RFC822 | ||
613 | # valid list of addresses. | ||
614 | # | ||
615 | # In list context, returns an empty list on failure (an invalid | ||
616 | # address was found); otherwise a list whose first element is the | ||
617 | # number of addresses found and whose remaining elements are the | ||
618 | # addresses. This is needed to disambiguate failure (invalid) | ||
619 | # from success with no addresses found, because an empty string is | ||
620 | # a valid list. | ||
621 | |||
622 | sub rfc822_validlist ($) { | ||
623 | my $s = rfc822_strip_comments(shift); | ||
624 | |||
625 | if (!$rfc822re) { | ||
626 | $rfc822re = make_rfc822re(); | ||
627 | } | ||
628 | # * null list items are valid according to the RFC | ||
629 | # * the '1' business is to aid in distinguishing failure from no results | ||
630 | |||
631 | my @r; | ||
632 | if ($s =~ m/^(?:$rfc822re)?(?:,(?:$rfc822re)?)*$/so && | ||
633 | $s =~ m/^$rfc822_char*$/) { | ||
634 | while($s =~ m/(?:^|,$rfc822_lwsp*)($rfc822re)/gos) { | ||
635 | push @r, $1; | ||
636 | } | ||
637 | return wantarray ? (scalar(@r), @r) : 1; | ||
638 | } | ||
639 | else { | ||
640 | return wantarray ? () : 0; | ||
641 | } | ||
642 | } | ||