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

When socket.io-client > 2.x.x, some unicode characters are broken. #566

Open
shortstories opened this issue Jun 5, 2018 · 4 comments
Open

Comments

@shortstories
Copy link

shortstories commented Jun 5, 2018

Hi.
I found a bug that breaking Unicode characters when trying to communicate as polling.
Especially, XHR polling works normally, and just JSONP polling causes problem.

This problem is related to the commit at socketio/engine.io-parser#81.
Since they remove utf-8 decoding from engine.io-parser, ISO-8859-1 decoded messages are passed to Socket.io event handler.

We can fix this problem by modifying PacketEncoder.processUtf8(). I test this and got expected result. However, in this case, the characters are broken when use socket.io-client 1.x.x.

I don't know if we should change the client codes, or change the server codes, or abandon the 1.x.x legacy codes. Let's consider this problem together.

@bfang711
Copy link

bfang711 commented Jun 22, 2018

Can you please let us know how you changed PacketEncoder.processUtf8() to make 2.x.x work?

Besides this utf-8 issue, are there any other issue that you encountered when use it with socket.io-client > 2.x.x?
thank you

@shortstories
Copy link
Author

shortstories commented Jun 26, 2018

@bfang711
see this PR.
c965ab9#diff-22d17f4eb2b7440b51933abadde882b8L99

PacketEncoder.processUtf8() make bytes as an ISO-8859-1 String and recreates it as UTF-8 bytes.
(+ \ -> \\, ' -> \')

So what you need to do to solve this problem is:

  1. Remove lines that make packet bytes as an ISO-8859-1 String. just make it as UTF-8 String.
  2. Do replace chars \ -> \\, ' -> \'.
  3. Change packet size header. In current source, it was written at PacketEncoder line 76. (The packet size is UTF-8 String length, not bytes length.)

With the release of socket-io-client 2.0, there were two breaking changes. (https://github.com/socketio/socket.io/releases/tag/2.0.0) This issue related to one of them. Because my project does not use custom namespace, so it does not seem to be affected by the other change. So I have not encounter any other issues yet.

@lianxiang1
Copy link

netty-socketio 1.7.16

@wzio
Copy link

wzio commented Jun 11, 2019

How can we fix it now? @lianxiang1

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

4 participants