You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the content-type header of the request is like "application/x-www-form-urlencoded; charset=UTF-8" the following logic is not functioning properly in the sendProxyRequest.js:
if (bodyContent.length) {
var body = bodyContent;
var contentType = proxyReq.getHeader('Content-Type');
if (contentType === 'x-www-form-urlencoded' || contentType === 'application/x-www-form-urlencoded') {
try {
var params = JSON.parse(body);
body = Object.keys(params).map(function(k) { return k + '=' + params[k]; }).join('&');
} catch (e) {
// bodyContent is not json-format
}
}
What ends up happening is the bodyContent is a JSON and it gets sent improperly.
The body-parser seems to have no issues with this content-type.
The contentType detection of urlencoded should not break if there is a semi-colon followed by the charset or other segments of the contentType.
As a work around - I can add a custom proxyReqOptDecorator and capture the content-type from the caller and "sanitize" the content-type and remove the semi-colon segment as a temporary fix. But I should not need to do that.
The text was updated successfully, but these errors were encountered:
I created the following PR with a potential fix: #489
codefactor
changed the title
sendProxyRequest does not handle content-type === "application/x-www-form-urlencoded; charset=UTF-8"
form-urlencoded requests do not proxy correctly if content-type contains a semi-colon
Oct 16, 2021
If the content-type header of the request is like "application/x-www-form-urlencoded; charset=UTF-8" the following logic is not functioning properly in the
sendProxyRequest.js
:What ends up happening is the bodyContent is a JSON and it gets sent improperly.
The body-parser seems to have no issues with this content-type.
The contentType detection of urlencoded should not break if there is a semi-colon followed by the charset or other segments of the contentType.
As a work around - I can add a custom
proxyReqOptDecorator
and capture the content-type from the caller and "sanitize" the content-type and remove the semi-colon segment as a temporary fix. But I should not need to do that.The text was updated successfully, but these errors were encountered: