Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-9830

XAROutputWikiStream: attachments are truncated after 4096 bytes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.3
    • Fix Version/s: 5.4-milestone-1
    • Component/s: Filter - XAR
    • Labels:
      None
    • Difficulty:
      Unknown
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      Description

      The onWikiAttachment method of the XAROutputWikiStream uses a 4096 byte size buffer to convert the input stream for the attachment to the XAR output stream.

      However to base64-enocode the stream, separate calls to Base64.encodeBase64String(buffer) are made. This utility assumes the input of every chunk is all there is to encode, and pads the results in a way that is interpreted as EOF when base64 decoding.

      Effectively, while the contents of the attachment are streamed out completely to the output, the stream is interrupted by EOF-markers every 4096 bytes, causing the attachment to look only 4096 bytes long when e.g. importing als XAR.

      Workaround: use a buffer size which is a multiple of 3 (e.g. 4095), which does not need padding the chunked results when base64 encoding.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                camil7 Clemens Robbenhaar
                Reporter:
                camil7 Clemens Robbenhaar
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Date of First Response: