Fix problem with buggy HTTP-Servers which send illegal control characters in HTTP-Headers, they are ignored now.

Thx to celle for the patch and see http://forum.yacy-websuche.de/viewtopic.php?f=6&t=560 for more information.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4235 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
fuchsi 18 years ago
parent 7d5544e9b1
commit 18e516317d

@ -1166,20 +1166,29 @@ public final class serverCore extends serverAbstractThread implements serverThre
// reuse an existing linebuffer
serverByteBuffer readLineBuffer = new serverByteBuffer(80);
serverByteBuffer temp = new serverByteBuffer(80);
int bufferSize = 0, b = 0;
try {
while ((b = pbis.read()) > 31) {
readLineBuffer.write(b);
try {
while ((b = pbis.read()) != cr) {
temp.write(b);
if (bufferSize++ > maxSize) break;
}
// we have catched a possible line end
if (b == cr) {
// maybe a lf follows, read it:
if ((b = pbis.read()) != lf) if (b >= 0) pbis.unread(b); // we push back the byte
}
// we have catched a possible line end
if (b == cr) {
// maybe a lf follows, read it:
if ((b = pbis.read()) != lf) if (b >= 0) pbis.unread(b); // we push back the byte
}
byte tempByte;
for(int i=0; i<temp.length(); i++){
tempByte = temp.byteAt(i);
// filter illegal bytes send by buggy HTTP servers
if( tempByte == 9 || (tempByte > 31 && tempByte != 127))
readLineBuffer.append(tempByte);
}
if ((readLineBuffer.length()==0)&&(b == -1)) return null;
return readLineBuffer.toByteArray();
} catch (ClosedByInterruptException e) {

Loading…
Cancel
Save