Author: remy.maucherat(a)jboss.com
Date: 2012-08-29 04:10:44 -0400 (Wed, 29 Aug 2012)
New Revision: 2072
Modified:
trunk/src/main/java/org/apache/coyote/ajp/AjpAprProcessor.java
trunk/src/main/java/org/apache/coyote/ajp/AjpMessage.java
trunk/src/main/java/org/apache/coyote/http11/AbstractInternalOutputBuffer.java
trunk/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java
trunk/src/main/java/org/apache/coyote/http11/Http11NioProcessor.java
trunk/src/main/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
trunk/src/main/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
Log:
Various minor byte handling cleanups.
Modified: trunk/src/main/java/org/apache/coyote/ajp/AjpAprProcessor.java
===================================================================
--- trunk/src/main/java/org/apache/coyote/ajp/AjpAprProcessor.java 2012-08-29 07:51:24 UTC
(rev 2071)
+++ trunk/src/main/java/org/apache/coyote/ajp/AjpAprProcessor.java 2012-08-29 08:10:44 UTC
(rev 2072)
@@ -967,7 +967,7 @@
int port = 0;
int mult = 1;
for (int i = valueL - 1; i > colonPos; i--) {
- int charValue = HexUtils.DEC[(int) valueB[i + valueS]];
+ int charValue = HexUtils.DEC[valueB[i + valueS] & 0xff];
if (charValue == -1) {
// Invalid character
error = true;
Modified: trunk/src/main/java/org/apache/coyote/ajp/AjpMessage.java
===================================================================
--- trunk/src/main/java/org/apache/coyote/ajp/AjpMessage.java 2012-08-29 07:51:24 UTC (rev
2071)
+++ trunk/src/main/java/org/apache/coyote/ajp/AjpMessage.java 2012-08-29 08:10:44 UTC (rev
2072)
@@ -242,10 +242,8 @@
// but is the only consistent approach within the current
// servlet framework. It must suffice until servlet output
// streams properly encode their output.
- if ((c <= 31) && (c != 9)) {
+ if (((c <= 31) && (c != 9)) || c == 127 || c > 255) {
c = ' ';
- } else if (c == 127) {
- c = ' ';
}
appendByte(c);
}
Modified: trunk/src/main/java/org/apache/coyote/http11/AbstractInternalOutputBuffer.java
===================================================================
---
trunk/src/main/java/org/apache/coyote/http11/AbstractInternalOutputBuffer.java 2012-08-29
07:51:24 UTC (rev 2071)
+++
trunk/src/main/java/org/apache/coyote/http11/AbstractInternalOutputBuffer.java 2012-08-29
08:10:44 UTC (rev 2072)
@@ -577,8 +577,7 @@
// but is the only consistent approach within the current
// servlet framework. It must suffice until servlet output
// streams properly encode their output.
-
- if ((c <= 31 && c != 9) || c == 127) {
+ if (((c <= 31) && (c != 9)) || c == 127 || c > 255) {
c = ' ';
}
Modified: trunk/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java
===================================================================
--- trunk/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java 2012-08-29
07:51:24 UTC (rev 2071)
+++ trunk/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java 2012-08-29
08:10:44 UTC (rev 2072)
@@ -1542,7 +1542,7 @@
int port = 0;
int mult = 1;
for (int i = valueL - 1; i > colonPos; i--) {
- int charValue = HexUtils.DEC[valueB[i + valueS]];
+ int charValue = HexUtils.DEC[valueB[i + valueS] & 0xff];
if (charValue == -1) {
// Invalid character
error = true;
Modified: trunk/src/main/java/org/apache/coyote/http11/Http11NioProcessor.java
===================================================================
--- trunk/src/main/java/org/apache/coyote/http11/Http11NioProcessor.java 2012-08-29
07:51:24 UTC (rev 2071)
+++ trunk/src/main/java/org/apache/coyote/http11/Http11NioProcessor.java 2012-08-29
08:10:44 UTC (rev 2072)
@@ -1078,7 +1078,7 @@
int port = 0;
int mult = 1;
for (int i = valueL - 1; i > colonPos; i--) {
- int charValue = HexUtils.DEC[valueB[i + valueS]];
+ int charValue = HexUtils.DEC[valueB[i + valueS] & 0xff];
if (charValue == -1) {
// Invalid character
error = true;
Modified: trunk/src/main/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
===================================================================
--- trunk/src/main/java/org/apache/coyote/http11/InternalAprOutputBuffer.java 2012-08-29
07:51:24 UTC (rev 2071)
+++ trunk/src/main/java/org/apache/coyote/http11/InternalAprOutputBuffer.java 2012-08-29
08:10:44 UTC (rev 2072)
@@ -675,10 +675,8 @@
// but is the only consistent approach within the current
// servlet framework. It must suffice until servlet output
// streams properly encode their output.
- if ((c <= 31) && (c != 9)) {
+ if (((c <= 31) && (c != 9)) || c == 127 || c > 255) {
c = ' ';
- } else if (c == 127) {
- c = ' ';
}
buf[pos++] = (byte) c;
}
Modified: trunk/src/main/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
===================================================================
---
trunk/src/main/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 2012-08-29
07:51:24 UTC (rev 2071)
+++
trunk/src/main/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 2012-08-29
08:10:44 UTC (rev 2072)
@@ -266,6 +266,7 @@
int result = 0;
boolean eol = false;
+ boolean crfound = false;
boolean readDigit = false;
boolean trailer = false;
@@ -282,7 +283,10 @@
}
if (buf[pos] == Constants.CR) {
+ if (crfound) throw new IOException("Invalid CRLF, two CR characters
encountered.");
+ crfound = true;
} else if (buf[pos] == Constants.LF) {
+ if (!crfound) throw new IOException("Invalid CRLF, no CR character
encountered.");
eol = true;
} else if (buf[pos] == Constants.SEMI_COLON) {
trailer = true;
@@ -290,7 +294,7 @@
throw new IOException("Invalid chunk header");
} else if (!trailer) {
//don't read data after the trailer
- if (HexUtils.DEC[buf[pos]] != -1) {
+ if (HexUtils.DEC[buf[pos] & 0xff] != -1) {
readDigit = true;
result *= 16;
result += HexUtils.DEC[buf[pos]];