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

XAROutputWikiStream: attachments are truncated after 4096 bytes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 5.4-milestone-1
    • 5.3
    • Filter - XAR
    • None
    • Unknown
    • N/A
    • N/A

    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

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

              Dates

                Created:
                Updated:
                Resolved: