This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=5a7c7badd9e8fabf04f6c0f2362c903f80e1c0ae commit 5a7c7badd9e8fabf04f6c0f2362c903f80e1c0ae Author: Guillem Jover <[email protected]> AuthorDate: Sun Oct 2 19:53:26 2022 +0200 Dpkg::Vendor: Fix vendor file loading for vendors with special characters The current code was not handling vendor names with multiple groups of spaces nor with special characters (any of [^A-Za-z0-9]). While filenames can be easily supported by many of those special characters, they can be annoying to deal with or cause unexpected results (such as using «/»). We add trials with full special character remapping to «-» using the same regex that we will use for vendor module names, so that the remapping is unified and more easy to understand. --- man/deb-origin.pod | 8 +++++--- scripts/Dpkg/Vendor.pm | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/man/deb-origin.pod b/man/deb-origin.pod index c0380c6d9..66fe46419 100644 --- a/man/deb-origin.pod +++ b/man/deb-origin.pod @@ -42,9 +42,11 @@ the field. The file should be named according to the vendor name. The usual convention is to name the vendor file using the vendor name in all lowercase, but some variation is permitted. -Namely, spaces are mapped to dashes (‘B<->’), and the file -can have the same casing as the value in B<Vendor> field, or it can -be capitalized. +Namely, non-alphanumeric characters (‘B<[^A-Za-z0-9]>’) are mapped to +dashes (‘B<->’), and lower-cased, as-is, lower-cased then capitalized +and capitalized (since dpkg 1.21.10). +In addition, the above casing attempts will be tried first as-is with +no remapping, and then by remapping spaces to dashes (‘B<->’). =head1 FIELDS diff --git a/scripts/Dpkg/Vendor.pm b/scripts/Dpkg/Vendor.pm index 7ad643e7d..e23996859 100644 --- a/scripts/Dpkg/Vendor.pm +++ b/scripts/Dpkg/Vendor.pm @@ -113,13 +113,23 @@ sub get_vendor_info(;$) { Check if there's a file for the given vendor and returns its name. +The vendor filename will be derived from the vendor name, by replacing any +number of non-alphanumeric characters (that is B<[^A-Za-z0-9]>) into "B<->", +then lower-casing, as-is, lower-casing then capitalizing, and capitalizing. + +In addition the above casing attempts will be tried also first as-is with +no replacements, and then by replacing only spaces to "B<->". + =cut sub get_vendor_file(;$) { my $vendor = shift || 'default'; - my @names = (lc $vendor, $vendor, ucfirst lc $vendor, ucfirst $vendor); - if ($vendor =~ s/\s+/-/) { + my @names; + my $vendor_sep = $vendor =~ s{$vendor_sep_regex}{-}gr; + push @names, lc $vendor_sep, $vendor_sep, ucfirst lc $vendor_sep, ucfirst $vendor_sep; + push @names, lc $vendor, $vendor, ucfirst lc $vendor, ucfirst $vendor; + if ($vendor =~ s{\s+}{-}g) { push @names, lc $vendor, $vendor, ucfirst lc $vendor, ucfirst $vendor; } foreach my $name (uniq @names) { -- Dpkg.Org's dpkg

