forked from I2P_Developers/i2p.i2p
* Specify locale in all toLowerCase() and toUpperCase() calls to
avoid "Turkish four i problem"
This commit is contained in:
@@ -46,6 +46,7 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
@@ -233,7 +234,7 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging {
|
||||
public void runCommand(String cmd, Logging l) {
|
||||
if (cmd.indexOf(" ") == -1) cmd += " ";
|
||||
int iii = cmd.indexOf(" ");
|
||||
String cmdname = cmd.substring(0, iii).toLowerCase();
|
||||
String cmdname = cmd.substring(0, iii).toLowerCase(Locale.US);
|
||||
String allargs = cmd.substring(iii + 1);
|
||||
String[] args = split(allargs, " "); // .split(" "); // java 1.4
|
||||
|
||||
|
@@ -11,6 +11,7 @@ import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
@@ -193,7 +194,7 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
|
||||
restofline = request.substring(pos); // ":80 HTTP/1.1" or " HTTP/1.1"
|
||||
}
|
||||
|
||||
if (host.toLowerCase().endsWith(".i2p")) {
|
||||
if (host.toLowerCase(Locale.US).endsWith(".i2p")) {
|
||||
// Destination gets the host name
|
||||
destination = host;
|
||||
} else if (host.indexOf(".") != -1) {
|
||||
@@ -209,7 +210,7 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
|
||||
destination = currentProxy;
|
||||
usingWWWProxy = true;
|
||||
newRequest.append("CONNECT ").append(host).append(restofline).append("\r\n"); // HTTP spec
|
||||
} else if (host.toLowerCase().equals("localhost")) {
|
||||
} else if (host.toLowerCase(Locale.US).equals("localhost")) {
|
||||
writeErrorMessage(ERR_LOCALHOST, out);
|
||||
s.close();
|
||||
return;
|
||||
@@ -224,7 +225,7 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
|
||||
_log.debug(getPrefix(requestId) + "REST :" + restofline + ":");
|
||||
_log.debug(getPrefix(requestId) + "DEST :" + destination + ":");
|
||||
}
|
||||
} else if (line.toLowerCase().startsWith("proxy-authorization: basic ")) {
|
||||
} else if (line.toLowerCase(Locale.US).startsWith("proxy-authorization: basic ")) {
|
||||
// strip Proxy-Authenticate from the response in HTTPResponseOutputStream
|
||||
// save for auth check below
|
||||
authorization = line.substring(27); // "proxy-authorization: basic ".length()
|
||||
|
@@ -336,7 +336,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug(getPrefix(requestId) + "Line=[" + line + "]");
|
||||
|
||||
String lowercaseLine = line.toLowerCase();
|
||||
String lowercaseLine = line.toLowerCase(Locale.US);
|
||||
if (lowercaseLine.startsWith("connection: ") ||
|
||||
lowercaseLine.startsWith("keep-alive: ") ||
|
||||
lowercaseLine.startsWith("proxy-connection: "))
|
||||
@@ -365,7 +365,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
}
|
||||
// "http://" + "foo.i2p/bar/baz.html" + " HTTP/1.0"
|
||||
request = "http://" + uri + subRequest.substring(protopos);
|
||||
} else if (request.toLowerCase().startsWith("http://i2p/")) {
|
||||
} else if (request.toLowerCase(Locale.US).startsWith("http://i2p/")) {
|
||||
// http://i2p/b64key/bar/baz.html HTTP/1.0
|
||||
String subRequest = request.substring("http://i2p/".length());
|
||||
int protopos = subRequest.indexOf(" ");
|
||||
@@ -433,11 +433,11 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
destination = host;
|
||||
host = getHostName(destination);
|
||||
line = method + ' ' + request.substring(pos);
|
||||
} else if (host.toLowerCase().equals(LOCAL_SERVER)) {
|
||||
} else if (host.toLowerCase(Locale.US).equals(LOCAL_SERVER)) {
|
||||
// so we don't do any naming service lookups
|
||||
destination = host;
|
||||
usingInternalServer = true;
|
||||
} else if (host.toLowerCase().endsWith(".i2p")) {
|
||||
} else if (host.toLowerCase(Locale.US).endsWith(".i2p")) {
|
||||
// Destination gets the host name
|
||||
destination = host;
|
||||
// Host becomes the destination's "{b32}.b32.i2p" string, or "i2p" on lookup failure
|
||||
@@ -498,7 +498,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
if (host == null || "i2p".equals(host)) {
|
||||
// Host lookup failed - resolvable only with addresshelper
|
||||
// Store in local HashMap unless there is conflict
|
||||
String old = addressHelpers.putIfAbsent(destination.toLowerCase(), ahelperKey);
|
||||
String old = addressHelpers.putIfAbsent(destination.toLowerCase(Locale.US), ahelperKey);
|
||||
ahelperNew = old == null;
|
||||
if ((!ahelperNew) && !old.equals(ahelperKey)) {
|
||||
// Conflict: handle when URL reconstruction done
|
||||
@@ -570,7 +570,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
line = method + " " + request.substring(pos);
|
||||
// end of (host endsWith(".i2p"))
|
||||
|
||||
} else if (host.toLowerCase().equals("localhost") || host.equals("127.0.0.1") ||
|
||||
} else if (host.toLowerCase(Locale.US).equals("localhost") || host.equals("127.0.0.1") ||
|
||||
host.startsWith("192.168.")) {
|
||||
// if somebody is trying to get to 192.168.example.com, oh well
|
||||
if (out != null) {
|
||||
@@ -804,15 +804,15 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
// look it up again as the naming service does not do negative caching
|
||||
// so it will be slow.
|
||||
Destination clientDest = null;
|
||||
String addressHelper = addressHelpers.get(destination.toLowerCase());
|
||||
String addressHelper = addressHelpers.get(destination.toLowerCase(Locale.US));
|
||||
if (addressHelper != null) {
|
||||
clientDest = _context.namingService().lookup(addressHelper);
|
||||
// remove bad entries
|
||||
if (clientDest == null)
|
||||
addressHelpers.remove(destination.toLowerCase());
|
||||
addressHelpers.remove(destination.toLowerCase(Locale.US));
|
||||
} else if ("i2p".equals(host)) {
|
||||
clientDest = null;
|
||||
} else if (destination.length() == 60 && destination.toLowerCase().endsWith(".b32.i2p")) {
|
||||
} else if (destination.length() == 60 && destination.toLowerCase(Locale.US).endsWith(".b32.i2p")) {
|
||||
// use existing session to look up for efficiency
|
||||
verifySocketManager();
|
||||
I2PSession sess = sockMgr.getSession();
|
||||
@@ -841,7 +841,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
header = getErrorPage("dnfp", ERR_DESTINATION_UNKNOWN);
|
||||
else if (ahelperPresent)
|
||||
header = getErrorPage("dnfb", ERR_DESTINATION_UNKNOWN);
|
||||
else if (destination.length() == 60 && destination.toLowerCase().endsWith(".b32.i2p"))
|
||||
else if (destination.length() == 60 && destination.toLowerCase(Locale.US).endsWith(".b32.i2p"))
|
||||
header = getErrorPage("dnf", ERR_DESTINATION_UNKNOWN);
|
||||
else {
|
||||
header = getErrorPage("dnfh", ERR_DESTINATION_UNKNOWN);
|
||||
@@ -984,7 +984,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
*/
|
||||
private final String getHostName(String host) {
|
||||
if (host == null) return null;
|
||||
if (host.length() == 60 && host.toLowerCase().endsWith(".b32.i2p"))
|
||||
if (host.length() == 60 && host.toLowerCase(Locale.US).endsWith(".b32.i2p"))
|
||||
return host;
|
||||
Destination dest = _context.namingService().lookup(host);
|
||||
if (dest == null) return "i2p";
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.i2p.i2ptunnel.irc;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -91,7 +92,7 @@ public class DCCClientManager extends EventReceiver {
|
||||
* @param localPort bind to port or 0; if nonzero it will be the rv
|
||||
*/
|
||||
private int newIncoming(String b32, int port, String type, int localPort) {
|
||||
b32 = b32.toLowerCase();
|
||||
b32 = b32.toLowerCase(Locale.US);
|
||||
// do some basic verification before starting the client
|
||||
if (b32.length() != 60 || !b32.endsWith(".b32.i2p"))
|
||||
return -1;
|
||||
|
@@ -2,6 +2,7 @@ package net.i2p.i2ptunnel.irc;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
@@ -130,7 +131,7 @@ abstract class IRCFilter {
|
||||
}
|
||||
// XDCC looks safe, ip/port happens over regular DCC
|
||||
// http://en.wikipedia.org/wiki/XDCC
|
||||
if (msg.toUpperCase().startsWith("XDCC ") && helper != null && helper.isEnabled())
|
||||
if (msg.toUpperCase(Locale.US).startsWith("XDCC ") && helper != null && helper.isEnabled())
|
||||
return s;
|
||||
if (ALLOW_ALL_CTCP_IN)
|
||||
return s;
|
||||
@@ -209,7 +210,7 @@ abstract class IRCFilter {
|
||||
if(field[0].charAt(0)==':')
|
||||
return null; // wtf
|
||||
|
||||
String command = field[0].toUpperCase();
|
||||
String command = field[0].toUpperCase(Locale.US);
|
||||
|
||||
if ("PING".equals(command)) {
|
||||
// Most clients just send a PING and are happy with any old PONG. Others,
|
||||
@@ -292,7 +293,7 @@ abstract class IRCFilter {
|
||||
return filterDCCOut(field[0] + ' ' + field[1] + " :\001DCC ", msg.substring(4), helper);
|
||||
// XDCC looks safe, ip/port happens over regular DCC
|
||||
// http://en.wikipedia.org/wiki/XDCC
|
||||
if (msg.toUpperCase().startsWith("XDCC ") && helper != null && helper.isEnabled())
|
||||
if (msg.toUpperCase(Locale.US).startsWith("XDCC ") && helper != null && helper.isEnabled())
|
||||
return s;
|
||||
if (ALLOW_ALL_CTCP_OUT)
|
||||
return s;
|
||||
|
@@ -14,6 +14,7 @@ import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.I2PException;
|
||||
@@ -198,8 +199,8 @@ public class SOCKS4aServer extends SOCKSServer {
|
||||
I2PSocket destSock;
|
||||
|
||||
try {
|
||||
if (connHostName.toLowerCase().endsWith(".i2p") ||
|
||||
connHostName.toLowerCase().endsWith(".onion")) {
|
||||
if (connHostName.toLowerCase(Locale.US).endsWith(".i2p") ||
|
||||
connHostName.toLowerCase(Locale.US).endsWith(".onion")) {
|
||||
_log.debug("connecting to " + connHostName + "...");
|
||||
// Let's not due a new Dest for every request, huh?
|
||||
//I2PSocketManager sm = I2PSocketManagerFactory.createManager();
|
||||
|
@@ -16,6 +16,7 @@ import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
@@ -355,7 +356,7 @@ public class SOCKS5Server extends SOCKSServer {
|
||||
I2PSocket destSock;
|
||||
|
||||
try {
|
||||
if (connHostName.toLowerCase().endsWith(".i2p")) {
|
||||
if (connHostName.toLowerCase(Locale.US).endsWith(".i2p")) {
|
||||
_log.debug("connecting to " + connHostName + "...");
|
||||
// Let's not due a new Dest for every request, huh?
|
||||
//I2PSocketManager sm = I2PSocketManagerFactory.createManager();
|
||||
|
@@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
@@ -185,10 +186,10 @@ public class IndexBean {
|
||||
else if ("start".equals(_action))
|
||||
return start();
|
||||
else if ("Save changes".equals(_action) || // IE workaround:
|
||||
(_action.toLowerCase().indexOf("s</span>ave") >= 0))
|
||||
(_action.toLowerCase(Locale.US).indexOf("s</span>ave") >= 0))
|
||||
return saveChanges();
|
||||
else if ("Delete this proxy".equals(_action) || // IE workaround:
|
||||
(_action.toLowerCase().indexOf("d</span>elete") >= 0))
|
||||
(_action.toLowerCase(Locale.US).indexOf("d</span>elete") >= 0))
|
||||
return deleteTunnel();
|
||||
else if ("Estimate".equals(_action))
|
||||
return PrivateKeyFile.estimateHashCashTime(_hashCashValue);
|
||||
|
Reference in New Issue
Block a user