487511 - Jetty HTTP won't work on turkish systems.

Fixed usages of toLowerCase() and toUpperCase() to use Locale.ENGLISH.
This commit is contained in:
Simone Bordet 2016-02-09 17:50:26 +01:00
parent e853632c22
commit 145e4bee71
8 changed files with 130 additions and 109 deletions

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.client;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.Locale;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.servlet.ServletException; import javax.servlet.ServletException;
@ -445,7 +446,7 @@ public class HttpClientURITest extends AbstractHttpClientServerTest
}); });
ContentResponse response = client.newRequest("localhost", connector.getLocalPort()) ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
.scheme(scheme.toUpperCase()) .scheme(scheme.toUpperCase(Locale.ENGLISH))
.timeout(5, TimeUnit.SECONDS) .timeout(5, TimeUnit.SECONDS)
.send(); .send();

View File

@ -18,6 +18,15 @@
package org.eclipse.jetty.http; package org.eclipse.jetty.http;
import java.nio.ByteBuffer;
import java.util.Enumeration;
import java.util.Locale;
import org.eclipse.jetty.util.BufferUtil;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
@ -25,13 +34,6 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.nio.ByteBuffer;
import java.util.Enumeration;
import org.eclipse.jetty.util.BufferUtil;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
/** /**
* *
*/ */
@ -134,11 +136,11 @@ public class HttpFieldsTest
BufferUtil.flipToFill(buffer); BufferUtil.flipToFill(buffer);
HttpGenerator.putTo(header,buffer); HttpGenerator.putTo(header,buffer);
BufferUtil.flipToFlush(buffer,0); BufferUtil.flipToFlush(buffer,0);
String out = BufferUtil.toString(buffer).toLowerCase(); String out = BufferUtil.toString(buffer).toLowerCase(Locale.ENGLISH);
Assert.assertThat(out,Matchers.containsString((HttpHeader.CONNECTION+": "+HttpHeaderValue.KEEP_ALIVE).toLowerCase())); Assert.assertThat(out,Matchers.containsString((HttpHeader.CONNECTION+": "+HttpHeaderValue.KEEP_ALIVE).toLowerCase(Locale.ENGLISH)));
Assert.assertThat(out,Matchers.containsString((HttpHeader.TRANSFER_ENCODING+": "+HttpHeaderValue.CHUNKED).toLowerCase())); Assert.assertThat(out,Matchers.containsString((HttpHeader.TRANSFER_ENCODING+": "+HttpHeaderValue.CHUNKED).toLowerCase(Locale.ENGLISH)));
Assert.assertThat(out,Matchers.containsString((HttpHeader.CONTENT_ENCODING+": "+HttpHeaderValue.GZIP).toLowerCase())); Assert.assertThat(out,Matchers.containsString((HttpHeader.CONTENT_ENCODING+": "+HttpHeaderValue.GZIP).toLowerCase(Locale.ENGLISH)));
} }
@Test @Test

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.quickstart; package org.eclipse.jetty.quickstart;
import java.util.Locale;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
@ -101,7 +103,7 @@ public class PreconfigureQuickStartWar
if (xml != null) if (xml != null)
{ {
if (xml.isDirectory() || !xml.toString().toLowerCase().endsWith(".xml")) if (xml.isDirectory() || !xml.toString().toLowerCase(Locale.ENGLISH).endsWith(".xml"))
error("Bad context.xml: "+xml); error("Bad context.xml: "+xml);
XmlConfiguration xmlConfiguration = new XmlConfiguration(xml.getURL()); XmlConfiguration xmlConfiguration = new XmlConfiguration(xml.getURL());
xmlConfiguration.configure(webapp); xmlConfiguration.configure(webapp);

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.quickstart; package org.eclipse.jetty.quickstart;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.util.Locale;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
@ -117,7 +118,7 @@ public class QuickStartWebApp extends WebAppContext
if (base.isDirectory()) if (base.isDirectory())
dir=base; dir=base;
else if (base.toString().toLowerCase().endsWith(".war")) else if (base.toString().toLowerCase(Locale.ENGLISH).endsWith(".war"))
{ {
war=base; war=base;
String w=war.toString(); String w=war.toString();

View File

@ -18,12 +18,33 @@
package org.eclipse.jetty.runner; package org.eclipse.jetty.runner;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import org.eclipse.jetty.security.ConstraintMapping; import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler; import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService; import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.security.authentication.BasicAuthenticator; import org.eclipse.jetty.security.authentication.BasicAuthenticator;
import org.eclipse.jetty.server.*; import org.eclipse.jetty.server.AbstractConnector;
import org.eclipse.jetty.server.handler.*; import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.ConnectorStatistics;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NCSARequestLog;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.ShutdownMonitor;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.server.handler.RequestLogHandler;
import org.eclipse.jetty.server.handler.StatisticsHandler;
import org.eclipse.jetty.server.session.SessionHandler; import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
@ -36,15 +57,6 @@ import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.xml.XmlConfiguration; import org.eclipse.jetty.xml.XmlConfiguration;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** /**
* Runner * Runner
@ -111,8 +123,9 @@ public class Runner
addJars(item); addJars(item);
else else
{ {
if (path.toLowerCase().endsWith(".jar") || String lowerCasePath = path.toLowerCase(Locale.ENGLISH);
path.toLowerCase().endsWith(".zip")) if (lowerCasePath.endsWith(".jar") ||
lowerCasePath.endsWith(".zip"))
{ {
URL url = item.getURL(); URL url = item.getURL();
_classpath.add(url); _classpath.add(url);
@ -424,7 +437,7 @@ public class Runner
contextPath = "/" + contextPath; contextPath = "/" + contextPath;
// Configure the context // Configure the context
if (!ctx.isDirectory() && ctx.toString().toLowerCase().endsWith(".xml")) if (!ctx.isDirectory() && ctx.toString().toLowerCase(Locale.ENGLISH).endsWith(".xml"))
{ {
// It is a context config file // It is a context config file
XmlConfiguration xmlConfiguration = new XmlConfiguration(ctx.getURL()); XmlConfiguration xmlConfiguration = new XmlConfiguration(ctx.getURL());

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.servlet; package org.eclipse.jetty.servlet;
import java.io.IOException; import java.io.IOException;
import java.util.Locale;
import javax.servlet.GenericServlet; import javax.servlet.GenericServlet;
import javax.servlet.ServletException; import javax.servlet.ServletException;
@ -125,7 +126,7 @@ public class JspPropertyGroupServlet extends GenericServlet
{ {
_dftServlet.getServlet().service(req,res); _dftServlet.getServlet().service(req,res);
} }
else if (_starJspMapped && pathInContext.toLowerCase().endsWith(".jsp")) else if (_starJspMapped && pathInContext.toLowerCase(Locale.ENGLISH).endsWith(".jsp"))
{ {
_jspServlet.getServlet().service(req,res); _jspServlet.getServlet().service(req,res);
} }

View File

@ -309,7 +309,7 @@ public class Module
System.err.printf("%nProceed (y/N)? "); System.err.printf("%nProceed (y/N)? ");
String line = input.readLine(); String line = input.readLine();
licenseAck = !(line == null || line.length() == 0 || !line.toLowerCase().startsWith("y")); licenseAck = !(line == null || line.length() == 0 || !line.toLowerCase(Locale.ENGLISH).startsWith("y"));
} }
} }

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.util.security;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
@ -152,7 +153,7 @@ public class Password extends Credential
if (b1<0 || b2<0) if (b1<0 || b2<0)
{ {
int i0 = (0xff&b1)*256 + (0xff&b2); int i0 = (0xff&b1)*256 + (0xff&b2);
String x = Integer.toString(i0, 36).toLowerCase(); String x = Integer.toString(i0, 36).toLowerCase(Locale.ENGLISH);
buf.append("U0000",0,5-x.length()); buf.append("U0000",0,5-x.length());
buf.append(x); buf.append(x);
} }
@ -161,7 +162,7 @@ public class Password extends Credential
int i1 = 127 + b1 + b2; int i1 = 127 + b1 + b2;
int i2 = 127 + b1 - b2; int i2 = 127 + b1 - b2;
int i0 = i1 * 256 + i2; int i0 = i1 * 256 + i2;
String x = Integer.toString(i0, 36).toLowerCase(); String x = Integer.toString(i0, 36).toLowerCase(Locale.ENGLISH);
int j0 = Integer.parseInt(x, 36); int j0 = Integer.parseInt(x, 36);
int j1 = (i0 / 256); int j1 = (i0 / 256);