[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231014-get-maintainers-utf8-v1-1-3af8c7aeb239@bang-olufsen.dk>
Date: Sat, 14 Oct 2023 19:22:44 +0200
From: Alvin Šipraga <alvin@...s.dk>
To: Joe Perches <joe@...ches.com>
Cc: Duje Mihanović <duje.mihanovic@...le.hr>,
Konstantin Ryabitsev <konstantin@...uxfoundation.org>,
linux-kernel@...r.kernel.org,
Alvin Šipraga <alsi@...g-olufsen.dk>
Subject: [PATCH] get_maintainer: correctly parse UTF-8 encoded names in
files
From: Alvin Šipraga <alsi@...g-olufsen.dk>
While the script correctly extracts UTF-8 encoded names from the
MAINTAINERS file, the regular expressions damage my name when parsing
from .yaml files. Fix this by replacing the Latin-1-compatible regular
expressions with the unicode property matcher \p{Latin}. It's also
necessary to instruct Perl to open all files with UTF-8 encoding.
The issue was also identified on the b4 mailing list [1]. This should
solve the observed side effects there as well.
Link: https://lore.kernel.org/all/20230726-gush-slouching-a5cd41@meerkat/ [1]
Signed-off-by: Alvin Šipraga <alsi@...g-olufsen.dk>
---
scripts/get_maintainer.pl | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index ab123b498fd9..cb78e11623a6 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -20,6 +20,7 @@ use Getopt::Long qw(:config no_auto_abbrev);
use Cwd;
use File::Find;
use File::Spec::Functions;
+use open qw(:std :encoding(UTF-8));
my $cur_path = fastgetcwd() . '/';
my $lk_path = "./";
@@ -442,7 +443,7 @@ sub maintainers_in_file {
my $text = do { local($/) ; <$f> };
close($f);
- my @poss_addr = $text =~ m$[A-Za-zÀ-ÿ\"\' \,\.\+-]*\s*[\,]*\s*[\(\<\{]{0,1}[A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+\.[A-Za-z0-9]+[\)\>\}]{0,1}$g;
+ my @poss_addr = $text =~ m$[\p{Latin}\"\' \,\.\+-]*\s*[\,]*\s*[\(\<\{]{0,1}[A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+\.[A-Za-z0-9]+[\)\>\}]{0,1}$g;
push(@file_emails, clean_file_emails(@poss_addr));
}
}
@@ -2460,13 +2461,13 @@ sub clean_file_emails {
$name = "";
}
- my @nw = split(/[^A-Za-zÀ-ÿ\'\,\.\+-]/, $name);
+ my @nw = split(/[^\p{Latin}\'\,\.\+-]/, $name);
if (@nw > 2) {
my $first = $nw[@nw - 3];
my $middle = $nw[@nw - 2];
my $last = $nw[@nw - 1];
- if (((length($first) == 1 && $first =~ m/[A-Za-z]/) ||
+ if (((length($first) == 1 && $first =~ m/\p{Latin}/) ||
(length($first) == 2 && substr($first, -1) eq ".")) ||
(length($middle) == 1 ||
(length($middle) == 2 && substr($middle, -1) eq "."))) {
---
base-commit: 70f8c6f8f8800d970b10676cceae42bba51a4899
change-id: 20231014-get-maintainers-utf8-32c65c4d6f8a
Powered by blists - more mailing lists