SmartBear / soapui

SoapUI is a free and open source cross-platform functional testing solution for APIs and web services.
http://www.soapui.org
Other
1.56k stars 607 forks source link

[Bug] Handling of Binary Data as String in AbstractMockRequest Leads to Data Corruption #795

Open sumsar1812 opened 8 months ago

sumsar1812 commented 8 months ago

When sending binary data (e.g., files with .lzma extension) via POST requests to SoapUI, the handling of the request in AbstractMockRequest (specifically at this line)) ) converts the incoming binary data into a String.

This approach is problematic for binary data, as the conversion process corrupts the data. This issue is evident when trying to save the received data to a file. The problem persists even when using getRawRequestData(), which, instead of returning the original byte array of the request, returns the byte array of the string representation, leading to further corruption.

A potential solution could be to modify the handling in AbstractMockRequest to avoid converting binary data into a String. Instead, it could directly work with the byte array. One approach might be to introduce a new field from around line 151 and utilize this field in getRawRequestData() to return the original binary data.

IvanovIlya116 commented 6 months ago

Hello. I need opened pull request for me.

IvanovIlya116 commented 6 months ago

https://github.com/SmartBear/soapui/pull/806

IvanovIlya116 commented 6 months ago

To rewrite the code to return a byte array method, you will have to rewrite most of the SoapUI core and test its functionality. I may not have studied the code well, but the method definitely expects an xml file, so I added the encoding detection and subsequent conversion to UTF-8 to the code, since there may be files with a different encoding.