From 9fb41fc8dcf90bed18b7b8e7ece99527abd56355 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Mon, 15 Jul 2024 09:59:55 +0200 Subject: [PATCH 1/2] remove some unused imports --- lib/MetaCPAN/Server/Controller/CVE.pm | 1 - lib/MetaCPAN/Server/Controller/Contributor.pm | 1 - lib/MetaCPAN/Server/Controller/Cover.pm | 1 - 3 files changed, 3 deletions(-) diff --git a/lib/MetaCPAN/Server/Controller/CVE.pm b/lib/MetaCPAN/Server/Controller/CVE.pm index d55f2123e..0fd0db983 100644 --- a/lib/MetaCPAN/Server/Controller/CVE.pm +++ b/lib/MetaCPAN/Server/Controller/CVE.pm @@ -4,7 +4,6 @@ use strict; use warnings; use Moose; -use MetaCPAN::Util qw( digest ); BEGIN { extends 'MetaCPAN::Server::Controller' } diff --git a/lib/MetaCPAN/Server/Controller/Contributor.pm b/lib/MetaCPAN/Server/Controller/Contributor.pm index e6529bd7e..f930800f5 100644 --- a/lib/MetaCPAN/Server/Controller/Contributor.pm +++ b/lib/MetaCPAN/Server/Controller/Contributor.pm @@ -4,7 +4,6 @@ use strict; use warnings; use Moose; -use MetaCPAN::Util qw( digest ); BEGIN { extends 'MetaCPAN::Server::Controller' } diff --git a/lib/MetaCPAN/Server/Controller/Cover.pm b/lib/MetaCPAN/Server/Controller/Cover.pm index 2e2f1ad79..1b0eefafb 100644 --- a/lib/MetaCPAN/Server/Controller/Cover.pm +++ b/lib/MetaCPAN/Server/Controller/Cover.pm @@ -4,7 +4,6 @@ use strict; use warnings; use Moose; -use MetaCPAN::Util qw( digest ); BEGIN { extends 'MetaCPAN::Server::Controller' } From c3c8e155e4915571089cb911b2b6e99d08df051e Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Mon, 15 Jul 2024 10:00:40 +0200 Subject: [PATCH 2/2] fix digest calculation from misuse or tr tr/// always transforms character classes. Trying to put a regex character class wrapped in brackets will result in the brackets getting transformed, and other characters getting converted incorrectly. Fix the tr/// used to generate a digest for an ID. This is only used for the contributors data, which is generally only updated when new releases are indexed. When querying the data, the author and release names are used, not the ID. The old records will continue to be found. If the data is reindexed, an additional record may be created for a release, but it should have the same data. After making this change, eventually all of the contributor data should be recalculated to make sure the IDs are correct, and the old records purged. But they shouldn't interfere with anything until that is done. --- lib/MetaCPAN/Util.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/MetaCPAN/Util.pm b/lib/MetaCPAN/Util.pm index 962ca4e97..46e4610ad 100644 --- a/lib/MetaCPAN/Util.pm +++ b/lib/MetaCPAN/Util.pm @@ -48,7 +48,7 @@ sub checkout_root { sub digest { my $digest = sha1_base64( join( "\0", grep {defined} @_ ) ); - $digest =~ tr/[+\/]/-_/; + $digest =~ tr{+/}{-_}; return $digest; }