Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send binary multipart formdata as base64? [duplicate]

Possible Duplicate:
How can you encode to Base64 using Javascript?

I have a web application based on Java, Wicket and JQuery which has a function to enable users to upload files (images, pdfs, rtf) through multipart/form-data.

Our web security infrastructure does filtering of all http traffic to pick up possibly malicious content e.g. XSS attacks, SQL injection, buffer overruns etc

The filter doesn't distinguish between normal text input fields and file data so it picks up false positives from many uploaded binary files, preventing those files from being uploaded. I cannot change the security policy.

It seems the best way around this would be for file data to be base-64 encoded so that it is sent with a Content-Transfer-Encoding:base64 similar to what email clients do.

Is there any way to direct the browser to transfer binary as base64 or some other non-binary format?

If not, could it be done manually with some JavaScript?

like image 386
David Avatar asked Jun 22 '12 03:06

David


1 Answers

It seems that you can set Content-Transfer-Encoding: base64
quote from W3C:

Each part may be encoded and the "Content-Transfer-Encoding" header supplied if the value of that part does not conform to the default (7BIT) encoding

http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2

Provided your Java Web Server in use doesn't ingore parameter Content-Transfer-Encoding.

like image 79
didxga Avatar answered Oct 14 '22 19:10

didxga