eduardtomasek / lz-string-python

lz-string for python 3
Do What The F*ck You Want To Public License
31 stars 42 forks source link

base64 incompatibility with the current lz-string version #13

Open nilp0inter opened 9 years ago

nilp0inter commented 9 years ago

Hi,

because of changes made in the encoding method of lz-string(https://github.com/pieroxy/lz-string/commit/2d5a419620ba0d9f6d2a046224f518a485caae3a), the javascript version can produce strings that can't be decompressed with this version.

This example raise an IndexError:

l=lzstring.LZString()
l.decompresFromBase64("A4cwdA9gtAcg9APyA===")

If anyone is interested I've found this https://github.com/pieroxy/lz-string/blob/0dda98caa06c4c09e251a96378538169dfbc5a5f/libs/lz-string.js as the last version compatible.

grischard commented 7 years ago

Unfortunately, this is still the case.

To save others some googling time, this is the error you'll get:

Traceback (most recent call last):
  File "lzstring.py", line 6, in <module>
    decoded = x.decompressFromBase64(data)
  File "/Users/grischard/code/lzstring/venv/lib/python3.6/site-packages/lzstring/__init__.py", line 685, in decompressFromBase64
    return self.decompress(output)
  File "/Users/grischard/code/lzstring/venv/lib/python3.6/site-packages/lzstring/__init__.py", line 563, in decompress
    data_val = ord(data_string[data_index])
IndexError: string index out of range
marcel-dancak commented 7 years ago

I had the same issues with newer versions of lz-string, so I made a new Python 3 version https://github.com/marcel-dancak/lz-string-python