Allow the DMARC pct field to be left empty in bind8

RFC 9989 (DMARCbis) removes the pct tag, but the DMARC form validated
the percentage as mandatory and always assigned it, so every record
written through Webmin contained pct=.

Treat the field like the sp field directly below it: when it is empty,
delete the tag. Values 0-100 are still accepted and validated for
anyone who deliberately uses pct during a rollout. join_dmarc() already
skips tags with an empty value, so no change was needed there.

Fixes #2843

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Deltaman-MWI
2026-09-15 13:05:08 +02:00
parent 3eb7493989
commit ee420bef24

View File

@@ -394,9 +394,14 @@ else {
my $dmarc = $r ? &parse_dmarc(@{$r->{'values'}}) : { };
$dmarc->{'p'} = $in{'dmarcp'};
$in{'dmarcpct'} =~ /^\d+$/ && $in{'dmarcpct'} >= 0 &&
$in{'dmarcpct'} <= 100 || &error($text{'edit_edmarcpct'});
$dmarc->{'pct'} = $in{'dmarcpct'};
if ($in{'dmarcpct'} ne '') {
$in{'dmarcpct'} =~ /^\d+$/ && $in{'dmarcpct'} >= 0 &&
$in{'dmarcpct'} <= 100 || &error($text{'edit_edmarcpct'});
$dmarc->{'pct'} = $in{'dmarcpct'};
}
else {
delete($dmarc->{'pct'});
}
if ($in{'dmarcsp'}) {
$dmarc->{'sp'} = $in{'dmarcsp'};