IMPORTANT FIX: small strings weren't getting a proper UTF-8 encoding (xkihzew)

`(.getBytes <string>)` was being used here instead of
`(.getBytes <string> "UTF-8")` as is correct and done elsewhere.

This means that small UTF-8 strings may have been incorrectly stored
in environments where UTF-8 is not the default JVM character encoding.

Bug was introduced in Nippy v2.6.0, released 9 days ago (2014 Mar 30).

*********************************************************************
Please check for possible errors in Unicode text written using Nippy
v2.6.0 if your JVM uses an alternative character encoding by default
*********************************************************************

Really sorry about this, not sure how this slipped in.

Thanks to @xkihzew for the bug report.
This commit is contained in:
Peter Taoussanis 2014-04-08 16:54:54 +07:00
parent b75e6d1adc
commit 7d84099074
2 changed files with 7 additions and 1 deletions

View file

@ -1,3 +1,9 @@
## v2.6.1 / 2014 Apr 8
> **CRITICAL FIX** for v2.6.0 released 9 days ago. Please upgrade ASAP!
## v2.6.0 / 2014 Mar 30 ## v2.6.0 / 2014 Mar 30
> **Major release** with efficiency improvements, reliability improvements, and some new utils. > **Major release** with efficiency improvements, reliability improvements, and some new utils.

View file

@ -186,7 +186,7 @@
(extend-type String ; Optimized common-case type (extend-type String ; Optimized common-case type
Freezable Freezable
(freeze-to-out* [x ^DataOutput out] (freeze-to-out* [x ^DataOutput out]
(let [ba (.getBytes x)] (let [ba (.getBytes x "UTF-8")]
(if (<= (alength ^bytes ba) Byte/MAX_VALUE) (if (<= (alength ^bytes ba) Byte/MAX_VALUE)
(do (write-id out id-string-small) (do (write-id out id-string-small)
(write-bytes out ba :small)) (write-bytes out ba :small))