orbiter 18 years ago
parent 1a45ecb356
commit e03fcf4627

@ -144,7 +144,7 @@ public class htmlFilterContentTransformer extends htmlFilterAbstractTransformer
// this is a text fragment, generate gettext quotation // this is a text fragment, generate gettext quotation
int ws = sbbs[i].whitespaceStart(true); int ws = sbbs[i].whitespaceStart(true);
int we = sbbs[i].whitespaceEnd(true); int we = sbbs[i].whitespaceEnd(true);
result.add(new String(sbbs[i].getBytes(ws, we))); result.add(new String(sbbs[i].getBytes(ws, we - ws)));
} }
} }
return result; return result;

@ -102,7 +102,7 @@ public final class httpChunkedOutputStream extends FilterOutputStream {
this.out.write(Integer.toHexString(len).getBytes()); this.out.write(Integer.toHexString(len).getBytes());
this.out.write(serverCore.crlf); this.out.write(serverCore.crlf);
this.out.write(b.getBytes(off, off + len)); this.out.write(b.getBytes(off, len));
this.out.write(serverCore.crlf); this.out.write(serverCore.crlf);
this.out.flush(); this.out.flush();
} }

@ -48,7 +48,7 @@ public class httpSSI {
parseSSI(referenceFile, in, start, q + 3 - start, out); parseSSI(referenceFile, in, start, q + 3 - start, out);
writeSSI(referenceFile, in, start + q + 3, out); writeSSI(referenceFile, in, start + q + 3, out);
} else if (p > 0) { } else if (p > 0) {
int q = in.indexOf("-->".getBytes(), start + 10); int q = in.indexOf("-->".getBytes(), p + 10);
out.write(in, start, p - start); out.write(in, start, p - start);
parseSSI(referenceFile, in, start + p, q + 3 - start - p, out); parseSSI(referenceFile, in, start + p, q + 3 - start - p, out);
writeSSI(referenceFile, in, start + q + 3, out); writeSSI(referenceFile, in, start + q + 3, out);

@ -179,7 +179,7 @@ public final class httpTemplate {
if (q >= 0) { if (q >= 0) {
// found a pattern // found a pattern
l.addAll(splitQuotation(new serverByteBuffer(text.getBytes(0, p)), qoff)); l.addAll(splitQuotation(new serverByteBuffer(text.getBytes(0, p)), qoff));
l.add(new serverByteBuffer(text.getBytes(p, q + right.length))); l.add(new serverByteBuffer(text.getBytes(p, q + right.length - p)));
text = new serverByteBuffer(text.getBytes(q + right.length)); text = new serverByteBuffer(text.getBytes(q + right.length));
} else { } else {
// found only pattern start, no closing parantesis (a syntax error that is silently accepted here) // found only pattern start, no closing parantesis (a syntax error that is silently accepted here)

@ -80,7 +80,7 @@ public class kelondroBufferedRA extends kelondroAbstractRA implements kelondroRA
} }
public int read(byte[] b, int off, int len) throws IOException { public int read(byte[] b, int off, int len) throws IOException {
byte[] g = sbb.getBytes((int) pos, (int) pos + len); byte[] g = sbb.getBytes((int) pos, len);
pos += g.length; pos += g.length;
System.arraycopy(g, 0, b, off, g.length); System.arraycopy(g, 0, b, off, g.length);
return g.length; return g.length;

@ -296,12 +296,12 @@ public final class serverByteBuffer extends OutputStream {
return getBytes(start, length); return getBytes(start, length);
} }
public byte[] getBytes(int start, int end) { public byte[] getBytes(int start, int len) {
// start is inclusive, end is exclusive // start is inclusive, end is exclusive
if (end > length) throw new IndexOutOfBoundsException("getBytes: end > length"); if (len > length) throw new IndexOutOfBoundsException("getBytes: len > length");
if (start > length) throw new IndexOutOfBoundsException("getBytes: start > length"); if (start > length) throw new IndexOutOfBoundsException("getBytes: start > length");
byte[] tmp = new byte[end - start]; byte[] tmp = new byte[len];
System.arraycopy(buffer, offset + start, tmp, 0, end - start); System.arraycopy(buffer, offset + start, tmp, 0, len);
return tmp; return tmp;
} }
@ -313,13 +313,12 @@ public final class serverByteBuffer extends OutputStream {
return this; return this;
} }
public serverByteBuffer trim(int start, int end) { public serverByteBuffer trim(int start, int len) {
// the end value is outside (+1) of the wanted target array // the end value is outside (+1) of the wanted target array
if (start > length) throw new IndexOutOfBoundsException("trim: start > length"); if (start > length) throw new IndexOutOfBoundsException("trim: start > length");
if (end > length) throw new IndexOutOfBoundsException("trim: end > length"); if (start + len > length) throw new IndexOutOfBoundsException("trim: start + len > length");
if (start > end) throw new IndexOutOfBoundsException("trim: start > end");
offset = offset + start; offset = offset + start;
length = end - start; length = len;
return this; return this;
} }
@ -337,7 +336,7 @@ public final class serverByteBuffer extends OutputStream {
r--; r--;
} }
if (l > r) r = l; if (l > r) r = l;
return trim(l, r); return trim(l, r - l);
} }
public int isUTF8char(int start) { public int isUTF8char(int start) {

Loading…
Cancel
Save