Author: markt Date: Thu May 4 20:33:13 2017 New Revision: 1793898 URL: http://svn.apache.org/viewvc?rev=1793898&view=rev Log: Simplify. Use Charset in preference to String
Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java tomcat/trunk/java/org/apache/catalina/connector/LocalStrings.properties Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1793898&r1=1793897&r2=1793898&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original) +++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Thu May 4 20:33:13 2017 @@ -1055,42 +1055,24 @@ public class CoyoteAdapter implements Ad CharChunk cc = uri.getCharChunk(); cc.allocate(length, -1); - String enc = connector.getURIEncoding(); - if (enc != null) { - B2CConverter conv = request.getURIConverter(); - try { - if (conv == null) { - conv = new B2CConverter(B2CConverter.getCharset(enc), true); - request.setURIConverter(conv); - } else { - conv.recycle(); - } - } catch (IOException e) { - log.error(sm.getString("coyoteAdapter.invalidEncoding")); - connector.setURIEncoding(null); - } - if (conv != null) { - try { - conv.convert(bc, cc, true); - uri.setChars(cc.getBuffer(), cc.getStart(), cc.getLength()); - return; - } catch (IOException ioe) { - // Should never happen as B2CConverter should replace - // problematic characters - request.getResponse().sendError( - HttpServletResponse.SC_BAD_REQUEST); - } - } + Charset charset = connector.getURICharset(); + + B2CConverter conv = request.getURIConverter(); + if (conv == null) { + conv = new B2CConverter(charset, true); + request.setURIConverter(conv); + } else { + conv.recycle(); } - // Default encoding: fast conversion for ISO-8859-1 - byte[] bbuf = bc.getBuffer(); - char[] cbuf = cc.getBuffer(); - int start = bc.getStart(); - for (int i = 0; i < length; i++) { - cbuf[i] = (char) (bbuf[i + start] & 0xff); + try { + conv.convert(bc, cc, true); + uri.setChars(cc.getBuffer(), cc.getStart(), cc.getLength()); + } catch (IOException ioe) { + // Should never happen as B2CConverter should replace + // problematic characters + request.getResponse().sendError(HttpServletResponse.SC_BAD_REQUEST); } - uri.setChars(cbuf, 0, length); } Modified: tomcat/trunk/java/org/apache/catalina/connector/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/LocalStrings.properties?rev=1793898&r1=1793897&r2=1793898&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/connector/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/catalina/connector/LocalStrings.properties Thu May 4 20:33:13 2017 @@ -19,7 +19,6 @@ coyoteAdapter.authorize=Authorizing user coyoteAdapter.checkRecycled.request=Encountered a non-recycled request and recycled it forcedly. coyoteAdapter.checkRecycled.response=Encountered a non-recycled response and recycled it forcedly. coyoteAdapter.debug=The variable [{0}] has value [{1}] -coyoteAdapter.invalidEncoding=Invalid URI encoding, using HTTP default coyoteAdapter.parsePathParam=Unable to parse the path parameters using encoding [{0}]. The path parameters in the URL will be ignored. coyoteConnector.invalidEncoding=The encoding [{0}] is not recognised by the JRE. The Connector will continue to use [{1}] --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org