soapui icon indicating copy to clipboard operation
soapui copied to clipboard

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

Open sumsar1812 opened this issue 2 years ago • 3 comments

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.

sumsar1812 avatar Jan 31 '24 08:01 sumsar1812

Hello. I need opened pull request for me.

IvanovIlya116 avatar Mar 27 '24 09:03 IvanovIlya116

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

IvanovIlya116 avatar Mar 27 '24 10:03 IvanovIlya116

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.

IvanovIlya116 avatar Mar 27 '24 12:03 IvanovIlya116