Browse Source

Fix in src/main/java/com/corundumstudio/socketio/protocol/PacketDecoder.java:

Fix parsing of binary packets in the case where the binary member's placeholder object contains the num and _placeholder members in the opposite order (num, _placeholder instead of _placeholder, num).

Some socket.io clients do this and it's valid.
master
Winston Li 9 years ago
parent
commit
b66bc0f421
  1. 6
      src/main/java/com/corundumstudio/socketio/protocol/PacketDecoder.java

6
src/main/java/com/corundumstudio/socketio/protocol/PacketDecoder.java

@ -252,7 +252,11 @@ public class PacketDecoder {
ByteBuf scanValue = Unpooled.copiedBuffer("{\"_placeholder\":true,\"num\":" + i + "}", CharsetUtil.UTF_8);
int pos = PacketEncoder.find(source, scanValue);
if (pos == -1) {
throw new IllegalStateException("Can't find attachment by index: " + i + " in packet source");
scanValue = Unpooled.copiedBuffer("{\"num\":" + i + ",\"_placeholder\":true}", CharsetUtil.UTF_8);
pos = PacketEncoder.find(source, scanValue);
if (pos == -1) {
throw new IllegalStateException("Can't find attachment by index: " + i + " in packet source");
}
}
ByteBuf prefixBuf = source.slice(source.readerIndex(), pos - source.readerIndex());

Loading…
Cancel
Save