MIME::QuotedPrint encode_qp emits LF instead of requested CRLF
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Start at MIMEQuotedPrint.encodeQuotedPrintable, where ordinary input newlines are emitted, and compare that handling with the existing use of eol for soft breaks. Add focused coverage for CRLF input and requested CRLF output, then run the upstream t/basic.t suite with both ./jperl and ./jperl --interpreter; done means exact CRLF bytes and all 13 tests pass.
Written by the indexing model from the issue text.
Description
Summary
PerlOnJava's bundled MIME::QuotedPrint provider emits LF line endings when
encode_qp is asked to use CRLF. This breaks Email::MIME::Encodings's
quoted-printable encoder, which is required to preserve RFC email line
endings.
Reproduction
Run the upstream Email::MIME::Encodings 1.317 test suite:
./jperl t/basic.t
./jperl --interpreter t/basic.t
The suite reports one failure in enc qp:
not ok 8 - enc qp
got: 'This is a test\nof various MIME=3Dstuff.=\n'
expected: 'This is a test\r\nof various MIME=3Dstuff.=\r\n'
The failure reproduces on both the JVM and interpreter backends. System Perl
passes the complete upstream suite: 13 tests successful.
A minimal provider-level reproducer is:
./jperl -MMIME::QuotedPrint -e 'my $x="a\r\nb"; my $y=encode_qp($x,"\r\n"); print unpack("H*",$y),"\n"'
The expected encoded bytes begin with 610d0a (a\\r\\n), but PerlOnJava
returns 610a (a\\n).
CPAN failure
The CPAN random-tester run 20260910-101908-8428 recorded FAIL for
Email::MIME::Encodings 1.317:
1/13 subtests failed; 1/2 test programs failed
The failing test is the distribution's stable t/basic.t test, assertion 8.
The distribution itself is pure Perl and has no external service or native
library prerequisite.
Technical cause
Email::MIME::Encodings::codec passes the requested EOL to
MIME::QuotedPrint::encode_qp:
return $sub->($what, $eol);
The PerlOnJava implementation in MIMEQuotedPrint.encodeQuotedPrintable
hardcodes LF when it encounters an input newline:
output.append(currentLine).append("\\n");
It should preserve the requested eol value (CRLF in this case). The same
implementation already uses eol for soft line breaks, so handling ordinary
newlines consistently with that parameter appears to be the missing piece.
Impact
Email and MIME libraries using PerlOnJava's quoted-printable provider can
produce non-conforming line endings even when explicitly requesting CRLF.
This can affect message serialization, canonicalization, signatures, and
interoperability with MIME consumers.
Suggested fix and regression coverage
Update MIMEQuotedPrint.encodeQuotedPrintable to append the requested EOL for
preserved newlines, while retaining existing binary-mode and CRLF-normalizing
behavior. Add a focused regression test that checks the exact bytes returned
by encode_qp for CRLF input and requested CRLF output, and run the
Email::MIME::Encodings test under both execution backends.
- Dominant language
- Perl
- Stars
- 64
- Forks
- 6
- Avg merge
- 5h 25m
- Merged PRs (30d)
- 157
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fglock/PerlOnJava
-
area:cpan-port bug
Difficulty 4/5 3-5 days Newbie friendliness 44/100
fglock/PerlOnJava#1459 ·
-
area:cpan-port bug
Difficulty 3/5 1-2 days Newbie friendliness 72/100
fglock/PerlOnJava#1457 ·
-
bug high-impact
Difficulty 3/5 1-2 days Newbie friendliness 67/100
fglock/PerlOnJava#1456 · 1 comment ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 72/100
fglock/PerlOnJava#1455 ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 68/100
fglock/PerlOnJava#1454 ·
All issues in fglock/PerlOnJava
Similar issues
-
1.severity: security
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
api7/lua-resty-saml#63 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100