Skip to content

Fix issue related to invalid characters in tags being submitted. #1322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/main/java/de/rwth/idsg/steve/web/validation/IdTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@Constraint(validatedBy = {IdTagValidator.class, IdTagListValidator.class})
public @interface IdTag {

String message() default "ID Tag can only contain upper or lower case letters, numbers and dot, colon, dash, underscore symbols";
String message() default "ID Tag can only contain upper or lower case letters, numbers and dot, colon, dash, underscore or hash symbols";

// Required by validation runtime
Class<?>[] groups() default {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public class IdTagValidator implements ConstraintValidator<IdTag, String> {

private static final String IDTAG_PATTERN = "^[a-zA-Z0-9.:_-]{1,20}$";
private static final String IDTAG_PATTERN = "^[a-zA-Z0-9.:_#-]{1,20}$";
private static final Pattern PATTERN = Pattern.compile(IDTAG_PATTERN);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,20 @@ public void testColon() {
Assertions.assertTrue(validator.isValid("VID:00XXXXXXXXXX", null));
}

@Test
public void testPoundSign() {
Assertions.assertTrue(validator.isValid("#test", null));
Assertions.assertTrue(validator.isValid("test#", null));
Assertions.assertTrue(validator.isValid("te##st", null));

// Tag provided by Webasto charge points
// https://github.com/steve-community/steve/pull/1322
Assertions.assertTrue(validator.isValid("#FreeCharging", null));
}

@Test
public void testCombined() {
Assertions.assertTrue(validator.isValid("1t.E-S_:t20", null));
Assertions.assertTrue(validator.isValid("1t.E-S_:t20#", null));
}

}