Skip to content

Commit eb6f12e

Browse files
committed
Update SQL.java
1 parent 597d1cd commit eb6f12e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • src/main/java/io/github/intisy/utils/custom

src/main/java/io/github/intisy/utils/custom/SQL.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
@SuppressWarnings("unused")
1313
public 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
}

0 commit comments

Comments
 (0)