royale-proxy / cr-proxy

A simple Clash Royale proxy, implementing the new encryption, built on top of Twisted in Python 3.5.
https://discord.gg/BuUtGPM
24 stars 7 forks source link

coc/message/reader.py read_string should return as string not bytes #3

Open akirarat opened 7 years ago

akirarat commented 7 years ago

Since reader is just a BufferedReader. self.read() will return a byte array. We should convert this into a UTF-8 string.

def read_string(self):
    length = self.read_int()
    if length == pow(2, 32) - 1:
        return b""
    else:
        try:
            decoded = self.read(length)
        except MemoryError:
            raise IndexError("String out of range.")
        else:
            return decoded