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

multipart/form-data windows-1251 #1194

Open
UncleVic opened this issue Mar 22, 2023 · 2 comments
Open

multipart/form-data windows-1251 #1194

UncleVic opened this issue Mar 22, 2023 · 2 comments

Comments

@UncleVic
Copy link

UncleVic commented Mar 22, 2023

I have a problem with decoding messages in the charset windows-1251.
If a form contains charset=windows-1251, data can't be decoded correctly. After parsing a request a string will be corrupted.

My payload, for example. The tag <ErrorText> contains the charset windows-1251

POST /api/v1/events/providers/ipay HTTP/1.1
X-Forwarded-Proto: https
Connection: close
Content-Length: 673
Content-Type: multipart/form-data; charset=windows-1251; boundary=BS_20230321154848
User-Agent: BS_SOU_749

--BS_20230321154848
Content-Disposition: form-data; name="XML"

<?xml version="1.0" encoding="windows-1251" ?>
<ServiceProvider_Request>
  <DateTime>20230321154848</DateTime>
  <Version>1</Version>
  <RequestType>TransactionResult</RequestType>
  <ServiceNo>1</ServiceNo>
  <PersonalAccount>2gzD17a7MHFpnQGZmGag75</PersonalAccount>
  <Currency>933</Currency>
  <RequestId>6888</RequestId>
  <TransactionResult>
    <TransactionId>356624</TransactionId>
    <ServiceProvider_TrxId>2gzD17a7MHFpnQGZmGag75</ServiceProvider_TrxId>
    <CardTerminal>888888</CardTerminal>
    <ErrorText>Îïåðàöèÿ îòìåíåíà</ErrorText>
  </TransactionResult>
</ServiceProvider_Request>
--BS_20230321154848--
@UncleVic
Copy link
Author

The Multer calls the Busboy constructor as Busboy({headers: req.headers, limits: limits, preservePath: preservePath}) after that, I have broken UTF8 string. If it be able to pass defParamCharset=latin1 we'll can decode a result string by iconv.decode(Buffer.from(stringFromBusboy, 'latin1'), 'win1251')

@Doc999tor
Copy link

I opened a PR for fixing this issue - #1210
Waiting for a review
@UncleVic maybe you could use the fork I until the PR is merged

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

No branches or pull requests

2 participants