For peace of mind, I'd like to specify that the UTF-8 encoding is used every time a string is turned into a byte array.
I only left the original getBytes() calls in some unit tests where UTF-8 conversions were unnecessary, as when dealing with Base32 or Base64 data, or when using it to generate a crypto key for testing purposes with a fixed string.
http://codereview.appspot.com/977046/diff/1/6 File java/common/src/main/java/org/apache/shindig/common/util/Base32.java (right): http://codereview.appspot.com/977046/diff/1/6#newcode40 java/common/src/main/java/org/apache/shindig/common/util/Base32.java:40: return ENCODER.encode(arg0).getBytes("US-ASCII"); You can use StringUtils.getBytesUsAscii which already convert ...
15 years, 8 months ago
(2010-05-04 08:45:43 UTC)
#2
http://codereview.appspot.com/977046/diff/1/6
File java/common/src/main/java/org/apache/shindig/common/util/Base32.java
(right):
http://codereview.appspot.com/977046/diff/1/6#newcode40
java/common/src/main/java/org/apache/shindig/common/util/Base32.java:40: return
ENCODER.encode(arg0).getBytes("US-ASCII");
You can use StringUtils.getBytesUsAscii which already convert the exception to
runtime exception.
http://codereview.appspot.com/977046/diff/1/23
File
java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultUrlGenerator.java
(right):
http://codereview.appspot.com/977046/diff/1/23#newcode85
java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultUrlGenerator.java:85:
jsChecksum = HashUtil.checksum(jsBuf.toString().getBytes("UTF-8"));
Maybe use StringUtils.getBytesUtf8 instead which already convert the exception
for you (an probably in many other places)
Issue 977046: Explicitly use UTF-8 when turning strings to byte arrays
Created 15 years, 8 months ago by jtarrio
Modified 15 years, 8 months ago
Reviewers: shindig.remailer_gmail.com, johnfargo, zhoresh
Base URL: http://svn.apache.org/repos/asf/shindig/trunk/
Comments: 2