mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve wall filter
This commit is contained in:
@@ -68,10 +68,20 @@ public class Lexer {
|
||||
|
||||
private int varIndex = -1;
|
||||
|
||||
protected CommentHandler commentHandler;
|
||||
|
||||
public Lexer(String input){
|
||||
this(input, true);
|
||||
}
|
||||
|
||||
public CommentHandler getCommentHandler() {
|
||||
return commentHandler;
|
||||
}
|
||||
|
||||
public void setCommentHandler(CommentHandler commentHandler) {
|
||||
this.commentHandler = commentHandler;
|
||||
}
|
||||
|
||||
public final char charAt(int index) {
|
||||
if (index >= text.length()) {
|
||||
return EOI;
|
||||
@@ -1008,4 +1018,9 @@ public class Lexer {
|
||||
public BigDecimal decimalValue() {
|
||||
return new BigDecimal(text.toCharArray(), mark, bufPos);
|
||||
}
|
||||
|
||||
public static interface CommentHandler {
|
||||
|
||||
boolean handle(Token lastToken, String comment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class NotAllowCommentException extends ParserException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public NotAllowCommentException(){
|
||||
super();
|
||||
this("comment not allow");
|
||||
}
|
||||
|
||||
public NotAllowCommentException(String message, Throwable e){
|
||||
|
||||
@@ -141,6 +141,10 @@ public class SQLSelectParser extends SQLParser {
|
||||
}
|
||||
|
||||
accept(Token.SELECT);
|
||||
|
||||
if (lexer.token() == Token.COMMENT) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
SQLSelectQueryBlock queryBlock = new SQLSelectQueryBlock();
|
||||
|
||||
|
||||
@@ -617,6 +617,10 @@ public class SQLStatementParser extends SQLParser {
|
||||
if (lexer.token() == (Token.FROM)) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.COMMENT) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
SQLName tableName = exprParser.name();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user