Home

Add a comment

 

Incorrect description for compressToEncodeURIComponent()

Found your library today, liking it but I immediately found a problem :( LZString.compressToEncodedURIComponent(value) is certainly URI safe, but alas not URL encoding safe, as "URL encoding" (the one used for URL Parameters and form posts), uses the "+" the same as %20, i.e. a space. A "+" needs to be encoded as %2B. There was and still is a lot of trouble hidden behind this little detail, and your library (or your description) is another victim: The sentence "compressToEncodedURIComponent produces ASCII strings representing the original string encoded in Base64 with a few tweaks to make these URI safe. Hence, you can send them to the server without thinking about URL encoding them. This saves bandwidth and CPU. These strings can be decompressed with decompressFromEncodedURIComponent. See the bullet point above for considerations about size." is incorrect. One still needs to to "URL encode" (this is so "+" turns into %2B, otherwise it will turn into a space later. encodeURIComponent() will do this, too (because they know about the trouble lurking). decodeURIComponent() will obviusly not decode "+" into space, but a web server will. So the method and the method's name is 100% correct, and nothing can be changed there for the sake of compatibility, but the description is wrong. And there should maybe be another method, lets say LZString.compressToURLEncoding(value), where "+" and "/" are replaced with "-" and "_". "=" is dropped at the end. This is what is commonly used as base64url' (RC7515). bastel

Incorrect description for compressToEncodeURIComponent()


Title
Body
HTML : b, strong, i, em, blockquote, br, p, pre, a href="", ul, ol, li, sub, sup
OpenID Login
Name
E-mail address
Website
Remember me Yes  No 

E-mail addresses are not publicly displayed, so please only leave your e-mail address if you would like to be notified when new comments are added to this blog entry (you can opt-out later).

Home