James Server
  1. James Server
  2. JAMES-846

RemoteDelivery convertTo7Bit() can corrupt message content.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.1
    • Fix Version/s: 2.3.2, 3.0.0
    • Component/s: Remote Delivery
    • Labels:
      None

      Description

      This is something I ran into while fixing the Geronimo javamail bugs, and noticed that the RemoteDelivery code has the same problem. In the convertTo7Bit() method, the transfer encoding is unconditionally set to either quoted-printable or base64 depending on the MIME type. This can make the content invalid when transmitted as mail

      To understand the reason, you need to understand how MimeMessage holds the content internally. The content can exist in one of two forms: 1) The real content object, or 2) the content encoded as a byte array. In case 1), the Content-Transfer-Encoding indicates how the content WILL BE encoded when written to a stream. In case 2), the Content-Transfer-Encoding indicates how the content IS encoded in the byte array. In the first case, setting the transfer encoding works ok. In the second case, it's changing how the already encoded information will be interpreted. I've confirmed this to be the case with the Sun implementation as well.

      I ran into the reverse aspect of this problem with the implementation of the 8BITMIME support. It was not sufficient to just set the Content-Transfer-Encoding header to convert this to 8bit. It was necessary to call getContent(), then set the same content back on the message. Once that was done, it was safe to change the Content-Transfer-Encoding header.

        Activity

        Hide
        Stefano Bagnara added a comment -

        Applied (with a small refactoring).

        Backported to v2.3 because this is a major issue leading to message corruption under some circumstance.

        Show
        Stefano Bagnara added a comment - Applied (with a small refactoring). Backported to v2.3 because this is a major issue leading to message corruption under some circumstance.
        Hide
        Stefano Bagnara added a comment -

        Great!! Thank you! This patch solve an issue I noticed since months on my james and I didn't find the time to track until today! Today I reproduced it and saw that your patch fixed it!

        I'm going to apply it.

        Show
        Stefano Bagnara added a comment - Great!! Thank you! This patch solve an issue I noticed since months on my james and I didn't find the time to track until today! Today I reproduced it and saw that your patch fixed it! I'm going to apply it.
        Hide
        Rick McGuire added a comment -

        Recommended patch for this error. In addition to setting the content, this only adjusts the transfer encoding if the current encoding is 8bit.

        Show
        Rick McGuire added a comment - Recommended patch for this error. In addition to setting the content, this only adjusts the transfer encoding if the current encoding is 8bit.

          People

          • Assignee:
            Stefano Bagnara
            Reporter:
            Rick McGuire
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development