improve wall filter

This commit is contained in:
wenshao
2013-04-01 20:05:46 +08:00
parent 7a49a6ce35
commit 032c5762e2
46 changed files with 1653 additions and 222 deletions
@@ -203,12 +203,12 @@ public class MySqlLexer extends Lexer {
}
}
}
protected final void scanString() {
{
boolean hasSpecial = false;
int startIndex = pos + 1;
int endIndex = -1; //text.indexOf('\'', startIndex);
int endIndex = -1; // text.indexOf('\'', startIndex);
for (int i = startIndex; i < text.length(); ++i) {
final char ch = text.charAt(i);
if (ch == '\\') {
@@ -219,13 +219,13 @@ public class MySqlLexer extends Lexer {
break;
}
}
if (endIndex == -1) {
throw new ParserException("unclosed str");
}
String stringVal = subString(startIndex, endIndex - startIndex);
// hasSpecial = stringVal.indexOf('\\') != -1;
// hasSpecial = stringVal.indexOf('\\') != -1;
if (!hasSpecial) {
this.stringVal = stringVal;
@@ -328,6 +328,8 @@ public class MySqlLexer extends Lexer {
}
public void scanComment() {
Token lastToken = this.token;
if (ch != '/' && ch != '-') {
throw new IllegalStateException();
}
@@ -374,8 +376,14 @@ public class MySqlLexer extends Lexer {
token = Token.MULTI_LINE_COMMENT;
}
if (token != Token.HINT && !isAllowComment()) {
throw new NotAllowCommentException();
if (token != Token.HINT) {
if (commentHandler != null && commentHandler.handle(lastToken, stringVal)) {
return;
}
if (!isAllowComment()) {
throw new NotAllowCommentException();
}
}
return;
@@ -64,10 +64,15 @@ public class MySqlSelectParser extends SQLSelectParser {
if (lexer.token() == Token.SELECT) {
lexer.nextToken();
if (lexer.token() == Token.HINT) {
this.exprParser.parseHints(queryBlock.getHints());
}
if (lexer.token() == Token.COMMENT) {
lexer.nextToken();
}
if (lexer.token() == (Token.DISTINCT)) {
queryBlock.setDistionOption(SQLSetQuantifier.DISTINCT);
@@ -235,6 +235,10 @@ public class MySqlStatementParser extends SQLStatementParser {
if (lexer.token() == Token.DELETE) {
lexer.nextToken();
if (lexer.token() == Token.COMMENT) {
lexer.nextToken();
}
if (identifierEquals(LOW_PRIORITY)) {
deleteStatement.setLowPriority(true);