Author: zothar
Date: 2006-11-12 19:17:45 +0000 (Sun, 12 Nov 2006)
New Revision: 10904
Modified:
trunk/freenet/src/freenet/support/Base64.java
trunk/freenet/src/freenet/support/SimpleFieldSet.java
Log:
Fix standards compliance bug in Base64: variable name said equals, but comments
and code used various other characters; standards mode not used anywhere else,
so if this is wrong somehow, please advise (Python 2.3's base64 module likes
the committed code). Fix return type from SimpleFIeldSet.getInt(String,int).
Modified: trunk/freenet/src/freenet/support/Base64.java
===================================================================
--- trunk/freenet/src/freenet/support/Base64.java 2006-11-12 04:02:24 UTC
(rev 10903)
+++ trunk/freenet/src/freenet/support/Base64.java 2006-11-12 19:17:45 UTC
(rev 10904)
@@ -12,8 +12,8 @@
* <P>NOTE! This class only does the padding that's normal in Base64
* if the 'true' flag is given to the encode() method. This is because
* Base64 requires that the length of the encoded text be a multiple
- * of four characters, padded with '_'. Without the 'true' flag, we don't
- * add these '_' characters.
+ * of four characters, padded with '='. Without the 'true' flag, we don't
+ * add these '=' characters.
*
* @author Stephen Blackheath
*/
@@ -104,15 +104,15 @@
case 1: outLen -= 2; break;
case 2: outLen -= 1; break;
}
- // Pad with '~' signs up to a multiple of four if requested.
+ // Pad with '=' signs up to a multiple of four if requested.
if (equalsPad)
while (outLen < out.length)
- out[outLen++] = '_';
+ out[outLen++] = '=';
return new String(out, 0, outLen);
}
/**
- * Handles the standards-compliant (padded with '~' signs) as well as our
+ * Handles the standards-compliant (padded with '=' signs) as well as our
* shortened form.
*/
public static byte[] decode(String inStr)
@@ -123,7 +123,7 @@
int inLength = in.length;
// Strip trailing equals signs.
- while ((inLength > 0) && (in[inLength-1] == '_'))
+ while ((inLength > 0) && (in[inLength-1] == '='))
inLength--;
int blocks = inLength/4;
Modified: trunk/freenet/src/freenet/support/SimpleFieldSet.java
===================================================================
--- trunk/freenet/src/freenet/support/SimpleFieldSet.java 2006-11-12
04:02:24 UTC (rev 10903)
+++ trunk/freenet/src/freenet/support/SimpleFieldSet.java 2006-11-12
19:17:45 UTC (rev 10904)
@@ -503,7 +503,7 @@
}
}
- public long getInt(String key, int def) {
+ public int getInt(String key, int def) {
String s = get(key);
if(s == null) return def;
try {