Bug#1064454: debian-policy: Restrict deb822 field names more (2/2)
From
Guillem Jover@1:229/2 to
Niels Thykier on Sat Aug 17 01:10:01 2024
[continued from previous message]
Subject: [PATCH] Dpkg::Control::HashCore: Restrict field names
FIXME: discuss, update manual pages, extend commit message.
---
scripts/Dpkg/Control/HashCore.pm | 4 ++--
scripts/t/Dpkg_Control.t | 28 +++++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/scripts/Dpkg/Control/HashCore.pm b/scripts/Dpkg/Control/HashCore.pm
index 08f35c57b..cea329cf4 100644
--- a/scripts/Dpkg/Control/HashCore.pm
+++ b/scripts/Dpkg/Control/HashCore.pm
@@ -221,8 +221,8 @@ sub parse {
my ($name, $value) = split /\s*:\s*/, $_, 2;
if (defined $name and $name =~ m/^\S+?$/) {
$parabody = 1;
- if ($lead eq '-') {
- $self->parse_error($desc, g_('field cannot start with a hyphen'));
+ if ($name !~ m{^[_]*[A-Za-z]+[A-Za-z0-9-]*[A-Za-z0-9]+$}) {
+ $self->parse_error($desc, g_('field name %s uses invalid format'), $name);
}
if (exists $self->{$name}) {
unless ($$self->{allow_duplicate}) {
diff --git a/scripts/t/Dpkg_Control.t b/scripts/t/Dpkg_Control.t
index 29311b8c8..8df78c227 100644
--- a/scripts/t/Dpkg_Control.t