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

Extra space character sometime produced by compressToUTF16 starting version 1.4.0 #273

Open
spirtechfgr opened this issue Feb 21, 2025 · 0 comments
Labels

Comments

@spirtechfgr
Copy link

spirtechfgr commented Feb 21, 2025

Since version 1.4.0-alpha, for some inputs, the output of compressToUTF16 ends with an extra space character compared to what versions 1.3.3 to 1.3.9 do.

For example, for 5-character input "rstuv" the output of compressToUTF16, expressed in big-endian hex, is
in version 1.3.9: 09e3 1c2b 417c 0704 0020
in version 1.4.1: 09e3 1c2b 417c 0704 0020 0020

This does not break interoperability, but is unfortunate, and goes in the direction opposite to what the release notes state:

Binary compatibility for compression is not guaranteed, meaning the output from this version may be different than the output produced by an older version. This is trailing characters that are useless that are now omitted.

That clearly has to do with the code there:

  compressToUTF16 : function (input) {
    if (input == null) return "";
    return LZString._compress(input, 15, function(a){return f(a+32);}) + " ";
  },

But a fix is NOT as simple as removing + " " which would loose binary compatibility for decompression with versions 1.3.9 and earlier (e.g. "r" would compress to 09e8 which fails to decompress on 1.3.9).

François Grieu

@Rycochet Rycochet added the bug label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants