Open jbalazerpfpt opened 2 weeks ago
Thanks for the patch. I have a few remarks:
use warnings FATAL => 'recursion';
$max_depth
is an outside configurable, so Perl's convention is to use CAPS in that case.depth
... is $part->depth
clear enough? Or should it be $part->nesting
?I think the depth
can be implemented like this:
package Mail::Message;
sub depth() { 0 }
package Mail::Message::Path;
sub depth() { $_[0]->container->message->depth + 1 } # or:
sub depth() { $_[0]->{MMP_depth} //= $_[0]->container->message->depth + 1 }
package ::Multipart;
$self->message->depth < $max_depth or croak;
undef $epilogue if $self->message->isPart ? $epilogue->nrLines : !$has_epilogue;
How much do you agree with me?
The fix to issue #16 introduced a bug. When a multipart body is nested inside another multipart, if the inner part had no epilogue (no blank lines between the end-delimiter at the end of the child multipart and the separator that follows) the fixed code would incorrectly add a blank line after the end-delimiter. That earlier fix was correct for a multipart at the message level, but incorrect for this multipart. See the attached test message multipart_close-delimiter_test_nested_no_epilogue_between_close-delimiters.eml.txt.
Intertwined with this issue, we've had a problem of unbounded recursion, and so we've made a change to track recursion depth. The epilogue fix relies on that depth counter to know if the multipart body is nested or not. Here's the combined set of changes: