Return-Path: X-Original-To: apmail-geronimo-dev-archive@www.apache.org Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D4307760F for ; Tue, 20 Sep 2011 13:48:34 +0000 (UTC) Received: (qmail 56686 invoked by uid 500); 20 Sep 2011 13:48:34 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 56606 invoked by uid 500); 20 Sep 2011 13:48:34 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 56599 invoked by uid 99); 20 Sep 2011 13:48:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2011 13:48:34 +0000 X-ASF-Spam-Status: No, hits=-2000.5 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2011 13:48:32 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id DB27FA4A28 for ; Tue, 20 Sep 2011 13:48:10 +0000 (UTC) Date: Tue, 20 Sep 2011 13:48:10 +0000 (UTC) From: "Frederik Lindberg (JIRA)" To: dev@geronimo.apache.org Message-ID: <1582858512.46203.1316526490893.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Created] (GERONIMO-6165) Soft linebreaks in quoted-printable body result in loss of first character on next line MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org Soft linebreaks in quoted-printable body result in loss of first character on next line --------------------------------------------------------------------------------------- Key: GERONIMO-6165 URL: https://issues.apache.org/jira/browse/GERONIMO-6165 Project: Geronimo Issue Type: Bug Security Level: public (Regular issues) Components: mail Affects Versions: 2.1 Environment: Google Appengine Reporter: Frederik Lindberg http://code.google.com/p/googleappengine/issues/detail?id=2675 When emails with quoted-printable body and soft linebreaks are processed, the first character after the soft break disappears, eg: hello th= ere! becomes hello thre! This is due to geronimo/mail/util/QuotedPrintableEncoder.java (current trunk: Revision 1173142) public int decode(byte[] data, int off, int length, OutputStream out) throws IOException incorrectly looking for a line ending as "\r\n", whereas at this point line ending are "\n". So, the code: else if (ch == '=') { // we found an encoded character. Reduce the 3 char sequence to one. // but first, make sure we have two characters to work with. if (off + 1 >= endOffset) { throw new IOException("Invalid quoted printable encoding"); } // convert the two bytes back from hex. byte b1 = data[off++]; byte b2 = data[off++]; // we've found an encoded carriage return. The next char needs to be a newline if (b1 == '\r') { if (b2 != '\n') { throw new IOException("Invalid quoted printable encoding"); } // this was a soft linebreak inserted by the encoding. We just toss this away // on decode. } else { does not recognize the line ending and instead takes '=' + '\n' + {next char} and looks it up as a QP byte (which just becomes 0x00 via decodingTable without any Exceptions). I believe the code should be: else if (ch == '=') { if (off >= endOffset) { throw new IOException("Invalid quoted printable encoding"); } byte b1 = data[off++]; if (b1 == '\n') { // do nothing, this is a soft linebreak } else { if (off >= endOffset) { throw new IOException("Invalid quoted printable encoding"); } b2 = data[off++]; out.write((b1 << 4) | b2); // 3 bytes in, one byte out bytesWritten++; } Thanks! Fred -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira