Skip to content

Commit 484698c

Browse files
committed
CODEC-145 Base64.encodeBase64String could better use newStringUsAscii (ditto encodeBase64URLSafeString)
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1789158 13f79535-47bb-0310-9956-ffa450edef68
1 parent ae83747 commit 484698c

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ The <action> type attribute can be add,update,fix,remove.
4545
<release version="1.11" date="2017-MM-DD" description="Feature and fix release.">
4646
<!-- The first attribute below should be the issue id; makes it easier to navigate in the IDE outline -->
4747

48+
<action issue="CODEC-145" dev="sebb" type="fix" due-to="Jesse Glick">Base64.encodeBase64String could better use newStringUsAscii (ditto encodeBase64URLSafeString)</action>
4849
<action issue="CODEC-144" dev="sebb" type="fix">BaseNCodec: encodeToString and encodeAsString methods are identical</action>
4950
<action issue="CODEC-232" dev="sebb" type="fix">URLCodec is neither immutable nor threadsafe</action>
5051
<action issue="CODEC-231" dev="sebb" type="fix">StringUtils.equals(CharSequence cs1, CharSequence cs2) can fail with String Index OBE</action>

src/main/java/org/apache/commons/codec/binary/Base64.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ public static byte[] encodeBase64(final byte[] binaryData) {
567567
* @since 1.4 (NOTE: 1.4 chunked the output, whereas 1.5 does not).
568568
*/
569569
public static String encodeBase64String(final byte[] binaryData) {
570-
return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
570+
return StringUtils.newStringUsAscii(encodeBase64(binaryData, false));
571571
}
572572

573573
/**
@@ -593,7 +593,7 @@ public static byte[] encodeBase64URLSafe(final byte[] binaryData) {
593593
* @since 1.4
594594
*/
595595
public static String encodeBase64URLSafeString(final byte[] binaryData) {
596-
return StringUtils.newStringUtf8(encodeBase64(binaryData, false, true));
596+
return StringUtils.newStringUsAscii(encodeBase64(binaryData, false, true));
597597
}
598598

599599
/**

0 commit comments

Comments
 (0)