Issue with the API endpoint for downloading Ticket attachments

Dears,

we are facing an issue when using the REST API 1.0 to download
attachments from our RT Ticketing system.

We are using version RT 4.4.3-2 (Debian).

When we upload a non-binary file to RT as an attachment to a ticket,
this file is not returned in the same way by the “Ticket Attachment
Content” API endpoint
(https://rt-wiki.bestpractical.com/wiki/REST#Ticket_Attachment_Content).

The documentation says that one has to remove the 2 lines (showing the
RT version and Status code of the request), but it does not mention that
it is stripping away newlines at the end of the non-binary file and
adding 3 carriage returns at the end of it.

This means that a file looking like:

original_file.txt (19 bytes)
b’Hello world;\n\n\n\n\n\n\n’

will look like this when downloaded via the “Ticket Attachment Content”
API endpoint:

original_file.txt (12 bytes)
b’RT/4.4.3-2 200 Ok\n\nHello world;\n\n\n’

We don’t mind the “RT/4.4.3-2 200 Ok\n” part of the returned statement,
but stripping away the ending carriage returns makes working with
sensitive artefacts impossible via the API.

The file uploaded to RT seems not to be stored in a modified way on the
server as it is correctly returned when downloaded via the web interface.

Any help or guidance on fixing this would be appreciated.

Best regards,
Thierry