mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve sql wall
This commit is contained in:
@@ -110,7 +110,7 @@ public class MySqlLexer extends Lexer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isAllowComment()) {
|
||||
if (!isAllowComment() && (isEOF() || !isSafeComment(stringVal))) {
|
||||
throw new NotAllowCommentException();
|
||||
}
|
||||
}
|
||||
@@ -446,7 +446,7 @@ public class MySqlLexer extends Lexer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isAllowComment()) {
|
||||
if (!isAllowComment() && (isEOF() || !isSafeComment(stringVal))) {
|
||||
throw new NotAllowCommentException();
|
||||
}
|
||||
|
||||
@@ -486,11 +486,38 @@ public class MySqlLexer extends Lexer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isAllowComment()) {
|
||||
if (!isAllowComment() && (isEOF() || !isSafeComment(stringVal))) {
|
||||
throw new NotAllowCommentException();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSafeComment(String comment) {
|
||||
if (comment == null) {
|
||||
return true;
|
||||
}
|
||||
comment = comment.toLowerCase();
|
||||
if (comment.indexOf("select") != -1 //
|
||||
|| comment.indexOf("delete") != -1 //
|
||||
|| comment.indexOf("insert") != -1 //
|
||||
|| comment.indexOf("update") != -1 //
|
||||
|| comment.indexOf("into") != -1 //
|
||||
|| comment.indexOf("where") != -1 //
|
||||
|| comment.indexOf("or") != -1 //
|
||||
|| comment.indexOf("and") != -1 //
|
||||
|| comment.indexOf("union") != -1 //
|
||||
|| comment.indexOf('\'') != -1 //
|
||||
|| comment.indexOf('=') != -1 //
|
||||
|| comment.indexOf('>') != -1 //
|
||||
|| comment.indexOf('<') != -1 //
|
||||
|| comment.indexOf('&') != -1 //
|
||||
|| comment.indexOf('|') != -1 //
|
||||
|| comment.indexOf('^') != -1 //
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user