Author: toad
Date: 2007-12-22 23:28:47 +0000 (Sat, 22 Dec 2007)
New Revision: 16798

Modified:
   trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
   trunk/freenet/src/freenet/clients/http/NinjaSpider.java
   trunk/freenet/src/freenet/clients/http/Toadlet.java
   trunk/freenet/src/freenet/crypt/HMAC.java
   trunk/freenet/src/freenet/crypt/Yarrow.java
   trunk/freenet/src/freenet/frost/message/FrostMessage.java
   trunk/freenet/src/freenet/node/DarknetPeerNode.java
   trunk/freenet/src/freenet/node/fcp/PeerNote.java
   trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
Log:
getBytes() -> getBytes("UTF-8")
ARGH: I thought I'd caught all of these!

Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyToadlet.java   2007-12-22 
23:12:29 UTC (rev 16797)
+++ trunk/freenet/src/freenet/clients/http/FProxyToadlet.java   2007-12-22 
23:28:47 UTC (rev 16798)
@@ -159,7 +159,7 @@
                                        L10n.addL10nSubstitution(option, 
"FProxyToadlet.backToFProxy", new String[] { "link", "/link" },
                                                        new String[] { "<a 
href=\"/\">", "</a>" });

-                                       byte[] pageBytes = 
pageNode.generate().getBytes();
+                                       byte[] pageBytes = 
pageNode.generate().getBytes("UTF-8");
                                        context.sendReplyHeaders(200, "OK", new 
MultiValueTable(), "text/html; charset=utf-8", pageBytes.length);
                                        context.writeData(pageBytes);
                                        return;
@@ -209,7 +209,7 @@
                        L10n.addL10nSubstitution(option, 
"FProxyToadlet.backToFProxy", new String[] { "link", "/link" },
                                        new String[] { "<a href=\"/\">", "</a>" 
});

-                       byte[] pageBytes = pageNode.generate().getBytes();
+                       byte[] pageBytes = 
pageNode.generate().getBytes("UTF-8");
                        context.sendReplyHeaders(200, "OK", new 
MultiValueTable(), "text/html; charset=utf-8", pageBytes.length);
                        context.writeData(pageBytes);
                }
@@ -568,7 +568,7 @@
                try{
                        bos.write(random);
                        bos.write(key.toString().getBytes("UTF-8"));
-                       bos.write(Long.toString(time / 
FORCE_GRAIN_INTERVAL).getBytes());
+                       bos.write(Long.toString(time / 
FORCE_GRAIN_INTERVAL).getBytes("UTF-8"));
                } catch (IOException e) {
                        throw new Error(e);
                }

Modified: trunk/freenet/src/freenet/clients/http/NinjaSpider.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/NinjaSpider.java     2007-12-22 
23:12:29 UTC (rev 16797)
+++ trunk/freenet/src/freenet/clients/http/NinjaSpider.java     2007-12-22 
23:28:47 UTC (rev 16798)
@@ -582,7 +582,7 @@
                                }
                        }
                        MultiValueTable responseHeaders = new MultiValueTable();
-                       byte[] responseBytes = pageNode.generate().getBytes();
+                       byte[] responseBytes = 
pageNode.generate().getBytes("UTF-8");
                        context.sendReplyHeaders(200, "OK", responseHeaders, 
"text/html; charset=utf-8", responseBytes.length);
                        context.writeData(responseBytes);
                } else if ("add".equals(action)) {

Modified: trunk/freenet/src/freenet/clients/http/Toadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/Toadlet.java 2007-12-22 23:12:29 UTC 
(rev 16797)
+++ trunk/freenet/src/freenet/clients/http/Toadlet.java 2007-12-22 23:28:47 UTC 
(rev 16798)
@@ -85,7 +85,7 @@
                StringBuffer pageBuffer = new StringBuffer();
                pageNode.generate(pageBuffer);
                toadletContext.sendReplyHeaders(405, "Operation not Supported", 
hdrtbl, "text/html; charset=utf-8", pageBuffer.length());
-               toadletContext.writeData(pageBuffer.toString().getBytes());
+               
toadletContext.writeData(pageBuffer.toString().getBytes("UTF-8"));
        }

        private String l10n(String key, String pattern, String value) {

Modified: trunk/freenet/src/freenet/crypt/HMAC.java
===================================================================
--- trunk/freenet/src/freenet/crypt/HMAC.java   2007-12-22 23:12:29 UTC (rev 
16797)
+++ trunk/freenet/src/freenet/crypt/HMAC.java   2007-12-22 23:28:47 UTC (rev 
16798)
@@ -3,6 +3,7 @@
  * http://www.gnu.org/ for further details of the GPL. */
 package freenet.crypt;

+import java.io.UnsupportedEncodingException;
 import java.util.Arrays;

 import freenet.support.HexUtil;
@@ -85,11 +86,12 @@
        }
     }

-    public static void main(String[] args) {
+    public static void main(String[] args) throws UnsupportedEncodingException 
{
        HMAC s=new HMAC(SHA1.getInstance());
        byte[] key=new byte[20];
        System.err.println("20x0b, 'Hi There':");
-       byte[] text="Hi There".getBytes();
+       byte[] text;
+       text = "Hi There".getBytes("UTF-8");

        for (int i=0; i<key.length; i++) key[i]=(byte)0x0b;

@@ -113,7 +115,7 @@
        key=new byte[20];
        System.err.println("20x0c, 'Test With Truncation':");
        for (int i=0; i<key.length; i++) key[i]=(byte)0x0c;
-       text="Test With Truncation".getBytes();
+       text="Test With Truncation".getBytes("UTF-8");
        mv=s.mac(key, text, 20);
        System.out.println(HexUtil.bytesToHex(mv, 0, mv.length));
        mv=s.mac(key, text, 12);

Modified: trunk/freenet/src/freenet/crypt/Yarrow.java
===================================================================
--- trunk/freenet/src/freenet/crypt/Yarrow.java 2007-12-22 23:12:29 UTC (rev 
16797)
+++ trunk/freenet/src/freenet/crypt/Yarrow.java 2007-12-22 23:28:47 UTC (rev 
16798)
@@ -12,6 +12,7 @@
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.net.InetAddress;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
@@ -734,7 +735,12 @@
        }

        private void consumeString(String str) {
-               byte[] b = str.getBytes();
+               byte[] b;
+               try {
+                       b = str.getBytes("UTF-8");
+               } catch (UnsupportedEncodingException e) {
+                       throw new Error(e);
+               }
                consumeBytes(b);
        }


Modified: trunk/freenet/src/freenet/frost/message/FrostMessage.java
===================================================================
--- trunk/freenet/src/freenet/frost/message/FrostMessage.java   2007-12-22 
23:12:29 UTC (rev 16797)
+++ trunk/freenet/src/freenet/frost/message/FrostMessage.java   2007-12-22 
23:28:47 UTC (rev 16798)
@@ -3,10 +3,10 @@
 import java.util.*;

 import freenet.client.*;
-import freenet.client.ClientMetadata;
-import freenet.client.InsertBlock;
 import freenet.keys.FreenetURI;
 import freenet.support.io.ArrayBucket;
+
+import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import freenet.client.InsertException;

@@ -279,7 +279,12 @@

        int moreTries = 50;

-       byte[] data = this.getXml().getBytes();
+       byte[] data;
+               try {
+                       data = this.getXml().getBytes("UTF-8");
+               } catch (UnsupportedEncodingException e1) {
+                       throw new Error(e1);
+               }
        InsertBlock block = null;

        do // until the message is inserted

Modified: trunk/freenet/src/freenet/node/DarknetPeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/DarknetPeerNode.java 2007-12-22 23:12:29 UTC 
(rev 16797)
+++ trunk/freenet/src/freenet/node/DarknetPeerNode.java 2007-12-22 23:28:47 UTC 
(rev 16798)
@@ -708,7 +708,11 @@
                }
                SimpleFieldSet fs = new SimpleFieldSet(true);
                fs.put("peerNoteType", 
Node.PEER_NOTE_TYPE_PRIVATE_DARKNET_COMMENT);
-               fs.putSingle("privateDarknetComment", 
Base64.encode(comment.getBytes()));
+               try {
+                       fs.putSingle("privateDarknetComment", 
Base64.encode(comment.getBytes("UTF-8")));
+               } catch (UnsupportedEncodingException e) {
+                       throw new Error(e);
+               }
                if(localFileNumber == -1) {
                        localFileNumber = writeNewExtraPeerDataFile(fs, 
Node.EXTRA_PEER_DATA_TYPE_PEER_NOTE);
                        synchronized(privateDarknetComment) {

Modified: trunk/freenet/src/freenet/node/fcp/PeerNote.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/PeerNote.java    2007-12-22 23:12:29 UTC 
(rev 16797)
+++ trunk/freenet/src/freenet/node/fcp/PeerNote.java    2007-12-22 23:28:47 UTC 
(rev 16798)
@@ -3,6 +3,8 @@
  * http://www.gnu.org/ for further details of the GPL. */
 package freenet.node.fcp;

+import java.io.UnsupportedEncodingException;
+
 import freenet.node.Node;
 import freenet.support.Base64;
 import freenet.support.SimpleFieldSet;
@@ -24,7 +26,11 @@
                SimpleFieldSet fs = new SimpleFieldSet(true);
                fs.putSingle("NodeIdentifier", nodeIdentifier);
                fs.putSingle("PeerNoteType", Integer.toString(peerNoteType));
-               fs.putSingle("NoteText", Base64.encode(noteText.getBytes(), 
true));
+               try {
+                       fs.putSingle("NoteText", 
Base64.encode(noteText.getBytes("UTF-8"), true));
+               } catch (UnsupportedEncodingException e) {
+                       throw new Error(e);
+               }
                return fs;
        }


Modified: 
trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java     
2007-12-22 23:12:29 UTC (rev 16797)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java     
2007-12-22 23:28:47 UTC (rev 16798)
@@ -176,7 +176,7 @@
                 int node1 = random.nextInt(NUMBER_OF_NODES);
                 Node randomNode = nodes[node1];
                 Logger.error(RealNodeRequestInsertTest.class,"Inserting: 
\""+dataString+"\" to "+node1);
-                byte[] data = dataString.getBytes();
+                byte[] data = dataString.getBytes("UTF-8");
                 ClientCHKBlock block;
                 block = ClientCHKBlock.encode(data, false, false, (short)-1, 
0);
                 ClientCHK chk = (ClientCHK) block.getClientKey();


Reply via email to