forked from I2P_Developers/i2p.i2p
replace more equalsIgnoreCase() calls
This commit is contained in:
@ -16,6 +16,7 @@ import java.io.OutputStream;
|
||||
import java.io.PipedInputStream;
|
||||
import java.io.PipedOutputStream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
@ -177,23 +178,24 @@ class HTTPResponseOutputStream extends FilterOutputStream {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Response header [" + key + "] = [" + val + "]");
|
||||
|
||||
if ("Connection".equalsIgnoreCase(key)) {
|
||||
String lcKey = key.toLowerCase(Locale.US);
|
||||
if ("connection".equals(lcKey)) {
|
||||
out.write("Connection: close\r\n".getBytes());
|
||||
connectionSent = true;
|
||||
} else if ("Proxy-Connection".equalsIgnoreCase(key)) {
|
||||
} else if ("proxy-connection".equals(lcKey)) {
|
||||
out.write("Proxy-Connection: close\r\n".getBytes());
|
||||
proxyConnectionSent = true;
|
||||
} else if ( ("Content-encoding".equalsIgnoreCase(key)) && ("x-i2p-gzip".equalsIgnoreCase(val)) ) {
|
||||
} else if ("content-encoding".equals(lcKey) && "x-i2p-gzip".equals(val.toLowerCase(Locale.US))) {
|
||||
_gzip = true;
|
||||
} else if ("Proxy-Authenticate".equalsIgnoreCase(key)) {
|
||||
} else if ("proxy-authenticate".equals(lcKey)) {
|
||||
// filter this hop-by-hop header; outproxy authentication must be configured in I2PTunnelHTTPClient
|
||||
} else {
|
||||
if ("Content-Length".equalsIgnoreCase(key)) {
|
||||
if ("content-length".equals(lcKey)) {
|
||||
// save for compress decision on server side
|
||||
try {
|
||||
_dataExpected = Long.parseLong(val);
|
||||
} catch (NumberFormatException nfe) {}
|
||||
} else if ("Content-Type".equalsIgnoreCase(key)) {
|
||||
} else if ("content-type".equals(lcKey)) {
|
||||
// save for compress decision on server side
|
||||
_contentType = val;
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
|
||||
}
|
||||
}
|
||||
|
||||
if (destination == null || !"CONNECT".equalsIgnoreCase(method)) {
|
||||
if (destination == null || method == null || !"CONNECT".equals(method.toUpperCase(Locale.US))) {
|
||||
writeErrorMessage(ERR_BAD_PROTOCOL, out);
|
||||
s.close();
|
||||
return;
|
||||
|
@ -758,7 +758,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
if (method == null || destination == null) {
|
||||
//l.log("No HTTP method found in the request.");
|
||||
if (out != null) {
|
||||
if ("http://".equalsIgnoreCase(protocol))
|
||||
if (protocol != null && "http://".equals(protocol.toLowerCase(Locale.US)))
|
||||
out.write(getErrorPage("denied", ERR_REQUEST_DENIED));
|
||||
else
|
||||
out.write(getErrorPage("protocol", ERR_BAD_PROTOCOL));
|
||||
@ -1188,7 +1188,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
}
|
||||
}
|
||||
****/
|
||||
return protocol.equalsIgnoreCase("http://");
|
||||
return protocol.toLowerCase(Locale.US).equals("http://");
|
||||
}
|
||||
|
||||
private final static byte[] ERR_404 =
|
||||
|
@ -10,6 +10,7 @@ import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.client.streaming.I2PSocketManager;
|
||||
@ -101,7 +102,8 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
|
||||
// Ref: RFC 2617
|
||||
// If the socket is an InternalSocket, no auth required.
|
||||
String authRequired = getTunnel().getClientOptions().getProperty(PROP_AUTH);
|
||||
if (Boolean.valueOf(authRequired).booleanValue() || "basic".equalsIgnoreCase(authRequired)) {
|
||||
if (Boolean.valueOf(authRequired).booleanValue() ||
|
||||
(authRequired != null && "basic".equals(authRequired.toLowerCase(Locale.US)))) {
|
||||
if (s instanceof InternalSocket) {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info(getPrefix(requestId) + "Internal access, no auth required");
|
||||
|
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
@ -507,16 +508,17 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
||||
else
|
||||
value = "";
|
||||
|
||||
if ("Accept-encoding".equalsIgnoreCase(name))
|
||||
if ("accept-encoding".equals(name.toLowerCase(Locale.US)))
|
||||
name = "Accept-encoding";
|
||||
else if ("X-Accept-encoding".equalsIgnoreCase(name))
|
||||
else if ("x-accept-encoding".equals(name.toLowerCase(Locale.US)))
|
||||
name = "X-Accept-encoding";
|
||||
|
||||
// For incoming, we remove certain headers to prevent spoofing.
|
||||
// For outgoing, we remove certain headers to improve anonymity.
|
||||
boolean skip = false;
|
||||
String lcName = name.toLowerCase(Locale.US);
|
||||
for (String skipHeader: skipHeaders) {
|
||||
if (skipHeader.equalsIgnoreCase(name)) {
|
||||
if (skipHeader.toLowerCase(Locale.US).equals(lcName)) {
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.i2p.client.streaming.I2PSocket;
|
||||
@ -202,13 +203,13 @@ public class I2PTunnelIRCServer extends I2PTunnelServer implements Runnable {
|
||||
idx++;
|
||||
|
||||
try {
|
||||
command = field[idx++];
|
||||
command = field[idx++].toUpperCase(Locale.US);
|
||||
} catch (IndexOutOfBoundsException ioobe) {
|
||||
// wtf, server sent borked command?
|
||||
throw new IOException("Dropping defective message: index out of bounds while extracting command.");
|
||||
}
|
||||
|
||||
if ("USER".equalsIgnoreCase(command)) {
|
||||
if ("USER".equals(command)) {
|
||||
if (field.length < idx + 4)
|
||||
throw new IOException("Too few parameters in USER message: " + s);
|
||||
// USER zzz1 hostname localhost :zzz
|
||||
@ -221,7 +222,7 @@ public class I2PTunnelIRCServer extends I2PTunnelServer implements Runnable {
|
||||
break;
|
||||
}
|
||||
buf.append(s).append("\r\n");
|
||||
if ("SERVER".equalsIgnoreCase(command))
|
||||
if ("SERVER".equals(command))
|
||||
break;
|
||||
}
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
|
@ -58,7 +58,7 @@ abstract class IRCFilter {
|
||||
if(field[0].charAt(0)==':')
|
||||
idx++;
|
||||
|
||||
try { command = field[idx++]; }
|
||||
try { command = field[idx++].toUpperCase(Locale.US); }
|
||||
catch (IndexOutOfBoundsException ioobe) // wtf, server sent borked command?
|
||||
{
|
||||
//_log.warn("Dropping defective message: index out of bounds while extracting command.");
|
||||
@ -74,9 +74,9 @@ abstract class IRCFilter {
|
||||
} catch(NumberFormatException nfe){}
|
||||
|
||||
|
||||
if ("PING".equalsIgnoreCase(command))
|
||||
if ("PING".equals(command))
|
||||
return "PING 127.0.0.1"; // no way to know what the ircd to i2ptunnel server con is, so localhost works
|
||||
if ("PONG".equalsIgnoreCase(command)) {
|
||||
if ("PONG".equals(command)) {
|
||||
// Turn the received ":irc.freshcoffee.i2p PONG irc.freshcoffee.i2p :127.0.0.1"
|
||||
// into ":127.0.0.1 PONG 127.0.0.1 " so that the caller can append the client's extra parameter
|
||||
// though, does 127.0.0.1 work for irc clients connecting remotely? and for all of them? sure would
|
||||
@ -93,12 +93,12 @@ abstract class IRCFilter {
|
||||
|
||||
// Allow all allowedCommands
|
||||
for(int i=0;i<allowedCommands.length;i++) {
|
||||
if(allowedCommands[i].equalsIgnoreCase(command))
|
||||
if(allowedCommands[i].equals(command))
|
||||
return s;
|
||||
}
|
||||
|
||||
// Allow PRIVMSG, but block CTCP.
|
||||
if("PRIVMSG".equalsIgnoreCase(command) || "NOTICE".equalsIgnoreCase(command))
|
||||
if("PRIVMSG".equals(command) || "NOTICE".equals(command))
|
||||
{
|
||||
String msg;
|
||||
msg = field[idx++];
|
||||
|
Reference in New Issue
Block a user