Subject: 2.8.2 build 26315 - blocked mail resend always fails: "Modification of a read-only value attempted at sub main::BlockedMailResend line 119"
Hi Thomas,
Since updating to ASSP 2.8.2(26315), every resend request for a blocked mail
(from the block report links) fails. The maillog shows:
Info: got resend blocked mail request from user@example.com for /usr/local/ASSP_V2/discarded/xxxx.eml
Info: resend: modifying mail header for xxxx.eml
Error: unable to process blockreport - Modification of a read-only value attempted at sub main::BlockedMailResend line 119.
Environment: Linux (Fedora 44), Perl 5.42.3, ASSP 2.8.2(26315).
Cause: build 26315 changed the header loop in BlockedMailResend (the
"regular users requested a resend ... unexpected denied" fix) to:
for my $line (split(/\r\n/o,$header), '') {
my $text;
my $adr;
$line =~ s/\r|\n//o;
...
The foreach variable aliases the literal '' constant, which is read-only, so
"$line =~ s/\r|\n//o;" dies on that last iteration. Minimal reproduction:
perl -e 'for my $l (split(/x/,"axb"), q{}) { $l =~ s/\r|\n//o }'
Modification of a read-only value attempted at -e line 1.
Suggested fix (iterate over a copy, so every element is writable):
- for my $line (split(/\r\n/o,$header), '') {
+ for my $line (@{[split(/\r\n/o,$header), '']}) {
I've applied this locally and resends work again. The same pattern
does not appear anywhere else in assp.pl.
Credit: the cause and this fix were identified by Claude (Anthropic's AI
assistant, via Claude Code). It traced the error in the maillog to this
loop, compared build 26315 against build 26299 to find the change that
introduced it, reproduced the problem, and wrote and tested the patch.
Thanks for ASSP!
Thank you for the fix.
I just fixed the code and will provide an update today.
Thomas