|
|
|
@ -117,67 +117,92 @@ public final class htmlFilterWriter extends Writer {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static char[] genTag0raw(String tagname, boolean opening, char[] tagopts) {
|
|
|
|
|
serverCharBuffer bb = new serverCharBuffer(tagname.length() + tagopts.length + 3);
|
|
|
|
|
bb.append('<');
|
|
|
|
|
if (!opening) {
|
|
|
|
|
bb.append('/');
|
|
|
|
|
}
|
|
|
|
|
bb.append(tagname);
|
|
|
|
|
if (tagopts.length > 0) {
|
|
|
|
|
// if (tagopts[0] == (byte) 32)
|
|
|
|
|
bb.append(tagopts);
|
|
|
|
|
// else bb.append((byte) 32).append(tagopts);
|
|
|
|
|
try {
|
|
|
|
|
serverCharBuffer bb = new serverCharBuffer(tagname.length() + tagopts.length + 3);
|
|
|
|
|
bb.append('<');
|
|
|
|
|
if (!opening) {
|
|
|
|
|
bb.append('/');
|
|
|
|
|
}
|
|
|
|
|
bb.append(tagname);
|
|
|
|
|
if (tagopts.length > 0) {
|
|
|
|
|
// if (tagopts[0] == (byte) 32)
|
|
|
|
|
bb.append(tagopts);
|
|
|
|
|
// else bb.append((byte) 32).append(tagopts);
|
|
|
|
|
}
|
|
|
|
|
bb.append('>');
|
|
|
|
|
return bb.getChars();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
// ignore this
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
bb.append('>');
|
|
|
|
|
return bb.getChars();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static char[] genTag1raw(String tagname, char[] tagopts, char[] text) {
|
|
|
|
|
serverCharBuffer bb = new serverCharBuffer(2 * tagname.length() + tagopts.length + text.length + 5);
|
|
|
|
|
bb.append('<').append(tagname);
|
|
|
|
|
if (tagopts.length > 0) {
|
|
|
|
|
// if (tagopts[0] == (byte) 32)
|
|
|
|
|
bb.append(tagopts);
|
|
|
|
|
// else bb.append((byte) 32).append(tagopts);
|
|
|
|
|
try {
|
|
|
|
|
serverCharBuffer bb = new serverCharBuffer(2 * tagname.length() + tagopts.length + text.length + 5);
|
|
|
|
|
bb.append('<').append(tagname);
|
|
|
|
|
if (tagopts.length > 0) {
|
|
|
|
|
// if (tagopts[0] == (byte) 32)
|
|
|
|
|
bb.append(tagopts);
|
|
|
|
|
// else bb.append((byte) 32).append(tagopts);
|
|
|
|
|
}
|
|
|
|
|
bb.append('>');
|
|
|
|
|
bb.append(text);
|
|
|
|
|
bb.append('<').append('/').append(tagname).append('>');
|
|
|
|
|
return bb.getChars();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
// ignore this
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
bb.append('>');
|
|
|
|
|
bb.append(text);
|
|
|
|
|
bb.append('<').append('/').append(tagname).append('>');
|
|
|
|
|
return bb.getChars();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static char[] genTag0(String tagname, Properties tagopts, char quotechar) {
|
|
|
|
|
char[] tagoptsx = (tagopts.size() == 0) ? null : genOpts(tagopts, quotechar);
|
|
|
|
|
serverCharBuffer bb = new serverCharBuffer(tagname.length() + ((tagoptsx == null) ? 0 : (tagoptsx.length + 1)) + tagname.length() + 2);
|
|
|
|
|
bb.append('<').append(tagname);
|
|
|
|
|
if (tagoptsx != null) {
|
|
|
|
|
bb.append(32);
|
|
|
|
|
bb.append(tagoptsx);
|
|
|
|
|
try {
|
|
|
|
|
char[] tagoptsx = (tagopts.size() == 0) ? null : genOpts(tagopts, quotechar);
|
|
|
|
|
serverCharBuffer bb = new serverCharBuffer(tagname.length() + ((tagoptsx == null) ? 0 : (tagoptsx.length + 1)) + tagname.length() + 2);
|
|
|
|
|
bb.append('<').append(tagname);
|
|
|
|
|
if (tagoptsx != null) {
|
|
|
|
|
bb.append(32);
|
|
|
|
|
bb.append(tagoptsx);
|
|
|
|
|
}
|
|
|
|
|
bb.append('>');
|
|
|
|
|
return bb.getChars();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
// ignore this
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
bb.append('>');
|
|
|
|
|
return bb.getChars();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static char[] genTag1(String tagname, Properties tagopts, char[] text, char quotechar) {
|
|
|
|
|
char[] gt0 = genTag0(tagname, tagopts, quotechar);
|
|
|
|
|
serverCharBuffer cb = new serverCharBuffer(gt0, gt0.length + text.length + tagname.length() + 3);
|
|
|
|
|
cb.append(text).append('<').append('/').append(tagname).append('>');
|
|
|
|
|
return cb.getChars();
|
|
|
|
|
try {
|
|
|
|
|
char[] gt0 = genTag0(tagname, tagopts, quotechar);
|
|
|
|
|
serverCharBuffer cb = new serverCharBuffer(gt0, gt0.length + text.length + tagname.length() + 3);
|
|
|
|
|
cb.append(text).append('<').append('/').append(tagname).append('>');
|
|
|
|
|
return cb.getChars();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
// ignore this
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// a helper method for pretty-printing of properties for html tags
|
|
|
|
|
public static char[] genOpts(Properties prop, char quotechar) {
|
|
|
|
|
Enumeration e = prop.propertyNames();
|
|
|
|
|
serverCharBuffer bb = new serverCharBuffer(prop.size() * 40);
|
|
|
|
|
String key;
|
|
|
|
|
while (e.hasMoreElements()) {
|
|
|
|
|
key = (String) e.nextElement();
|
|
|
|
|
bb.append(32).append(key).append('=').append(quotechar);
|
|
|
|
|
bb.append(prop.getProperty(key));
|
|
|
|
|
bb.append(quotechar);
|
|
|
|
|
try {
|
|
|
|
|
Enumeration e = prop.propertyNames();
|
|
|
|
|
serverCharBuffer bb = new serverCharBuffer(prop.size() * 40);
|
|
|
|
|
String key;
|
|
|
|
|
while (e.hasMoreElements()) {
|
|
|
|
|
key = (String) e.nextElement();
|
|
|
|
|
bb.append(32).append(key).append('=').append(quotechar);
|
|
|
|
|
bb.append(prop.getProperty(key));
|
|
|
|
|
bb.append(quotechar);
|
|
|
|
|
}
|
|
|
|
|
if (bb.length() > 0) return bb.getChars(1);
|
|
|
|
|
return bb.getChars();
|
|
|
|
|
}catch (IOException e) {
|
|
|
|
|
// ignore this
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (bb.length() > 0) return bb.getChars(1);
|
|
|
|
|
return bb.getChars();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private char[] filterTag(String tag, boolean opening, char[] content, char quotechar) {
|
|
|
|
|