public static final int ADAPTER_NOTES = 1;
+ protected static final boolean ALLOW_BACKSLASH =
+ Boolean.valueOf(System.getProperty("org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH", "false")).booleanValue();
+
+
// ----------------------------------------------------------- Constructors
req.getURLDecoder().convert(decodedURI, false);
} catch (IOException ioe) {
res.setStatus(400);
- res.setMessage("Invalid URI");
- throw ioe;
+ res.setMessage("Invalid URI: " + ioe.getMessage());
+ return false;
}
// Normalization
if (!normalize(req.decodedURI())) {
// Replace '\' with '/'
// Check for null byte
for (pos = start; pos < end; pos++) {
- if (b[pos] == (byte) '\\')
- b[pos] = (byte) '/';
- if (b[pos] == (byte) 0)
+ if (b[pos] == (byte) '\\') {
+ if (ALLOW_BACKSLASH) {
+ b[pos] = (byte) '/';
+ } else {
+ return false;
+ }
+ }
+ if (b[pos] == (byte) 0) {
return false;
+ }
}
// The URL must start with '/'
private static org.apache.juli.logging.Log log=
org.apache.juli.logging.LogFactory.getLog(UDecoder.class );
+ protected static final boolean ALLOW_ENCODED_SLASH =
+ Boolean.valueOf(System.getProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "false")).booleanValue();
+
public UDecoder()
{
}
if( idx2 >= 0 && idx2 < idx ) idx=idx2;
if( idx < 0 ) idx=idx2;
+ boolean noSlash = !(ALLOW_ENCODED_SLASH || query);
+
for( int j=idx; j<end; j++, idx++ ) {
if( buff[ j ] == '+' && query) {
buff[idx]= (byte)' ' ;
j+=2;
int res=x2c( b1, b2 );
+ if (noSlash && (res == '/')) {
+ throw new CharConversionException( "noSlash");
+ }
buff[idx]=(byte)res;
}
}