Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

form-urlencoded requests do not proxy correctly if content-type contains a semi-colon #488

Open
codefactor opened this issue Oct 16, 2021 · 2 comments

Comments

@codefactor
Copy link

codefactor commented 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:

      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.

@codefactor
Copy link
Author

I created the following PR with a potential fix:
#489

@codefactor 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
@codefactor
Copy link
Author

I proposed a straight forward issue with a straight forward fix, no comments and no follow-up?
Any tips to get something done here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants