Issue1599900

classification
Title: Incorrect usage of String.getBytes()
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: akuchling, cgroves
Priority: normal Keywords:

Created on 2006-11-20.18:46:38 by akuchling, last changed 2007-12-02.20:38:29 by cgroves.

Messages
msg1286 (view) Author: A.M. Kuchling (akuchling) Date: 2006-11-20.18:46:38
I submitted a patch that fixes problems with the SHA
module.

One problem was the use of java.lang.String.getBytes() without
specifying some encoding; this resulted in bad results where the first
character of a hash value was >256.  Presumably the encoding on my Mac
is UTF-8.  The fix is to do getBytes("ISO-8859-1"); this in turn
requires catching an UnsupportedEncodingException.

Other portions of code that just call .getBytes() may also need changing,
wherever strings are being treated as containing 8-bit characters.

Possible files that need fixing: FilelikeInputStream.java,
parser.java, Py.java, PyArray, PyFile, binascii.java, and of course
PyString.  zlib.py's adler32() function also uses getBytes and I think
it needs to be fixed, too.
msg1287 (view) Author: Charlie Groves (cgroves) Date: 2006-12-31.21:31:54
Use the method to_bytes(String) added to PyString in r3038 to do the conversion.  This also handles when the String has values greater than 255 in it unlike getBytes("ISO-8859-1")
msg1288 (view) Author: Charlie Groves (cgroves) Date: 2007-12-02.20:38:29
The rest of the places using getBytes were fixed in 2.2.1.
History
Date User Action Args
2006-11-20 18:46:38akuchlingcreate