@Override
public List<ValidationError> validate()
{
clear();
if (this.document.size() == 0 && !this.shouldBeEmpty) {
this.errors.add(new ValidationError(Type.WARNING, 0, 0, "Unexpected empty response"));
}
if (this.document.size() > 0 && this.shouldBeEmpty) {
this.errors.add(new ValidationError(Type.WARNING, 0, 0, "Unexpected non-empty content: \"" + getContent() + "\""));
}
int lineNr = 1;
for (String line : this.document) {
checkStringDelimiters(line, lineNr);
checkTagDelimiter(line, lineNr, TEST_LT, "Unescaped < character");
checkTagDelimiter(line, lineNr, TEST_GT, "Unescaped > character");
int idx;
if ((idx = line.indexOf("Error while parsing velocity page")) >= 0) {
this.errors.add(new ValidationError(Type.WARNING, lineNr, idx,
"Parse error in the response. The template was not evaluated correctly."));
}
if ((idx = line.indexOf("org.xwiki.rendering.macro.MacroExecutionException")) >= 0) {
this.errors.add(new ValidationError(Type.WARNING, lineNr, idx,
"Macro execution exception in the response."));
}
if ((idx = line.indexOf("Wrapped Exception: unexpected char:")) >= 0) {
this.errors.add(new ValidationError(Type.WARNING, lineNr, idx, "Possible SQL error trace."));
}
// TODO also check \ for JavaScript
// TODO check for overescaping
lineNr++;
}