File tree Expand file tree Collapse file tree
src/main/java/io/github/intisy/utils/custom Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111
1212@ SuppressWarnings ("unused" )
1313public class SQL implements AutoCloseable {
14+ private final String validCharacters = "[A-Za-z0-9_-]+" ;
1415 private final String url ;
1516 private String username ;
1617 private String password ;
@@ -96,7 +97,7 @@ public void deleteData(String tableName, String... whereClause) {
9697 }
9798
9899 private boolean isInvalidIdentifier (String identifier ) {
99- return ! identifier .matches ("[A-Za-z0-9_-]+" );
100+ return identifier != null && ! identifier .matches (validCharacters );
100101 }
101102
102103 private String buildDeleteStatement (String tableName , String ... whereClause ) {
@@ -252,7 +253,7 @@ public void insertDataIfEmpty(String tableName, Object... columnsAndValues) {
252253
253254 private boolean isInvalidIdentifier (Object [] identifier ) {
254255 for (Object object : identifier )
255- if (! object .toString ().split (" " )[0 ].matches ("[A-Za-z0-9_-]+" )) {
256+ if (object != null && (! object .toString ().split ("' " )[1 ]. split ( "'" )[ 0 ].matches (validCharacters ) || ! object . toString (). split ( " " )[ 0 ]. matches ( validCharacters ) )) {
256257 Log .error ("Invalid identifier: " + object .toString ().split (" " )[0 ]);
257258 return true ;
258259 }
You can’t perform that action at this time.
0 commit comments