Skip to content

Commit 2cb32b8

Browse files
committed
[CODEC-185] Added clarification concerning the use of the urlSafe parameter to Base64.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1635986 13f79535-47bb-0310-9956-ffa450edef68
1 parent d2d7574 commit 2cb32b8

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ The <action> type attribute can be add,update,fix,remove.
4343
</properties>
4444
<body>
4545
<release version="1.10" date="DD Mmmm 2014" description="Feature and fix release.">
46+
<action dev="tn" type="fix" issue="CODEC-185" due-to="Sean Busbey">Added clarification to javadoc of Base64 concerning the use of the urlSafe parameter</action>
4647
<action dev="tn" type="fix" issue="CODEC-191" due-to="Igor Savin">Added clarification to the javadoc of Base[32|64]OutputStream that it is mandatory to call close()</action>
4748
<action dev="ggregory" type="fix" issue="CODEC-188" due-to="Hendrik Saly">Add support for HMAC Message Authentication Code (MAC) digests</action>
4849
<action dev="ggregory" type="fix" issue="CODEC-187" due-to="Michael Tobias, Thomas Neidhart">Beider Morse Phonetic Matching producing incorrect tokens</action>

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
* <li>Line separator: Default is CRLF ("\r\n")</li>
3737
* </ul>
3838
* <p>
39+
* The URL-safe parameter is only applied to encode operations. Decoding seamlessly handles both modes.
40+
* </p>
41+
* <p>
3942
* Since this class operates directly on byte streams, and not character streams, it is hard-coded to only
4043
* encode/decode character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252,
4144
* UTF-8, etc).
@@ -675,7 +678,10 @@ public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunk
675678
}
676679

677680
/**
678-
* Decodes a Base64 String into octets
681+
* Decodes a Base64 String into octets.
682+
* <p>
683+
* <b>Note:</b> this method seamlessly handles data encoded in URL-safe or normal mode.
684+
* </p>
679685
*
680686
* @param base64String
681687
* String containing Base64 data
@@ -687,7 +693,10 @@ public static byte[] decodeBase64(final String base64String) {
687693
}
688694

689695
/**
690-
* Decodes Base64 data into octets
696+
* Decodes Base64 data into octets.
697+
* <p>
698+
* <b>Note:</b> this method seamlessly handles data encoded in URL-safe or normal mode.
699+
* </p>
691700
*
692701
* @param base64Data
693702
* Byte array containing Base64 data
@@ -701,7 +710,7 @@ public static byte[] decodeBase64(final byte[] base64Data) {
701710

702711
// Implementation of integer encoding used for crypto
703712
/**
704-
* Decodes a byte64-encoded integer according to crypto standards such as W3C's XML-Signature
713+
* Decodes a byte64-encoded integer according to crypto standards such as W3C's XML-Signature.
705714
*
706715
* @param pArray
707716
* a byte array containing base64 character data
@@ -713,7 +722,7 @@ public static BigInteger decodeInteger(final byte[] pArray) {
713722
}
714723

715724
/**
716-
* Encodes to a byte64-encoded integer according to crypto standards such as W3C's XML-Signature
725+
* Encodes to a byte64-encoded integer according to crypto standards such as W3C's XML-Signature.
717726
*
718727
* @param bigInt
719728
* a BigInteger

0 commit comments

Comments
 (0)