mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-04 14:52:24 -05:00
From coverity: use UTF-8 encoding in Hex conversion methods
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2239 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
372b24fd3c
commit
a16ae1203b
@ -22,6 +22,7 @@ import org.apache.commons.codec.DecoderException;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -296,10 +297,10 @@ public final class StringUtil {
|
||||
* @param value base64 value
|
||||
* @return hex value
|
||||
*/
|
||||
public static String base64ToHex(String value) {
|
||||
public static String base64ToHex(String value) throws UnsupportedEncodingException {
|
||||
String hexValue = null;
|
||||
if (value != null) {
|
||||
hexValue = new String(Hex.encodeHex(Base64.decodeBase64(value.getBytes())));
|
||||
hexValue = new String(Hex.encodeHex(Base64.decodeBase64(value.getBytes("UTF-8"))));
|
||||
}
|
||||
return hexValue;
|
||||
}
|
||||
@ -311,10 +312,10 @@ public final class StringUtil {
|
||||
* @return base64 value
|
||||
* @throws DecoderException on error
|
||||
*/
|
||||
public static String hexToBase64(String value) throws DecoderException {
|
||||
public static String hexToBase64(String value) throws DecoderException, UnsupportedEncodingException {
|
||||
String base64Value = null;
|
||||
if (value != null) {
|
||||
base64Value = new String(Base64.encodeBase64(Hex.decodeHex(value.toCharArray())));
|
||||
base64Value = new String(Base64.encodeBase64(Hex.decodeHex(value.toCharArray())), "UTF-8");
|
||||
}
|
||||
return base64Value;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user