Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class BasicPostgresSecurityValidator implements PostgresSecurityValidator
* Documentation</a>
*/
private static final String DEFAULT_IDENTIFIER_PATTERN =
"^[a-zA-Z_][a-zA-Z0-9_]*(\\.[a-zA-Z_][a-zA-Z0-9_]*)*$";
"^[a-zA-Z_][a-zA-Z0-9_-]*(\\.[a-zA-Z_][a-zA-Z0-9_-]*)*$";

/**
* Default pattern for JSON field names within JSONB columns.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ void testValidIdentifierWithNumbers() {
assertDoesNotThrow(() -> validator.validateIdentifier("col_1"));
}

@Test
void testValidIdentifierWithHyphens() {
assertDoesNotThrow(() -> validator.validateIdentifier("API.repo-url"));
}

@Test
void testInvalidIdentifierNull() {
SecurityException ex =
Expand Down Expand Up @@ -75,13 +80,6 @@ void testInvalidIdentifierSqlInjection_Semicolon() {
assertTrue(ex.getMessage().contains("invalid"));
}

@Test
void testInvalidIdentifierHyphen() {
SecurityException ex =
assertThrows(SecurityException.class, () -> validator.validateIdentifier("field-name"));
assertTrue(ex.getMessage().contains("invalid"));
}

@Test
void testValidIdentifierWithDotNotation() {
assertDoesNotThrow(() -> validator.validateIdentifier("field.name"));
Expand Down
Loading