// Ensure that the specified encoding is valid
byte buffer[] = new byte[1];
buffer[0] = (byte) 'a';
- @SuppressWarnings("unused")
- String s = new String(buffer, enc);
+ // Confirm that the encoding name is valid
+ B2CConverter.getCharset(enc);
+
// Save the validated encoding
coyoteRequest.setCharacterEncoding(enc);
-
}
import org.apache.catalina.connector.Request;
import org.apache.catalina.util.RequestUtil;
import org.apache.coyote.Constants;
+import org.apache.tomcat.util.buf.B2CConverter;
/**
* An implementation of SSIExternalResolver that is used with servlets.
if (inputEncoding == null) {
retVal = new String( bytes );
} else {
- retVal = new String (bytes, inputEncoding);
+ retVal = new String (bytes,
+ B2CConverter.getCharset(inputEncoding));
}
//make an assumption that an empty response is a failure. This is
import java.io.UnsupportedEncodingException;
+import org.apache.tomcat.util.buf.B2CConverter;
import org.apache.tomcat.util.buf.ByteChunk;
import org.apache.tomcat.util.buf.CharChunk;
String result;
try {
- result = new String(encodedData, "ISO-8859-1");
+ result = new String(encodedData,
+ B2CConverter.getCharset("ISO-8859-1"));
} catch (UnsupportedEncodingException e) {
// Should never happen but in case it does...
result = new String(encodedData);