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

version compatibility between js and PHP implementation? #3

Closed
aelgoa opened this issue Sep 26, 2014 · 7 comments
Closed

version compatibility between js and PHP implementation? #3

aelgoa opened this issue Sep 26, 2014 · 7 comments

Comments

@aelgoa
Copy link

aelgoa commented Sep 26, 2014

js: LZString.compressToBase64(document.getElementById('src').value);
php: $s=LZString::decompressFromBase64($_POST['s']);

value is caught by PHP script as intented with correct value. error happens in decompression:


Notice: Uninitialized string offset: 1123 in D:\babs\8.5\root\wwide\LZString.php on line 354

Warning: strpos() [function.strpos]: Empty delimiter in D:\babs\8.5\root\wwide\LZString.php on line 354

Fatal error: Uncaught exception 'Exception' with message '$c != $dictSize (133,128)' in D:\babs\8.5\root\wwide\LZString.php:313 Stack trace: #0 D:\babs\8.5\root\wwide\LZString.php(380): LZString::decompress('???????????????...') #1 D:\babs\8.5\root\wwide\wwc.php(6): LZString::decompressFromBase64('MQSwdgxgNgrgJgU...') #2 {main}

thrown in D:\babs\8.5\root\wwide\LZString.php on line 313

@ymc-sise
Copy link

I can reproduce this. Same error for me.

@mattpass
Copy link
Contributor

I get the same issue too. Any ideas what can be done to fix it yet?

@nuald
Copy link

nuald commented Mar 11, 2015

Looks like it's related to base64 encoding, 3rd party Base64 decode + LZString.decompress work correctly (so far at least, the original issue doesn't have 100% reproducibility).

@ghost
Copy link

ghost commented May 5, 2015

If you're passing the base64 data directly via URL, the PHP decoding process replaces the pluses with spaces which are not valid base64 characters. You may need to retrieve the parameter from the query string, then replace any spaces with pluses before base64 decode or decodeFromBase64.

Escaping before passing the data may also resolve it.

@nullpunkt
Copy link
Owner

Hi, i've completely rewritten the PHP component to match the current algorythm / ouput provided by the javascript component. The bug is fixed in version 1.1.0.

@mattpass
Copy link
Contributor

That's awesome - many thanks!! 👍 Definitely going to check this out.

@Tarekajaj
Copy link

Awesome. just tested the new version and all the (too much errors) were gone.

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

6 participants