Skip to content

Commit

Permalink
Add support for : in profile names
Browse files Browse the repository at this point in the history
  • Loading branch information
leepa authored and millems committed Jun 30, 2020
1 parent 022970e commit 0883321
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class ProfileFileReader {

private static final Pattern EMPTY_LINE = Pattern.compile("^[\t ]*$");

private static final Pattern VALID_IDENTIFIER = Pattern.compile("^[A-Za-z0-9_\\-/.%@]*$");
private static final Pattern VALID_IDENTIFIER = Pattern.compile("^[A-Za-z0-9_\\-/.%@:]*$");

private ProfileFileReader() {
}
Expand Down Expand Up @@ -214,7 +214,7 @@ private static Optional<String> parseProfileDefinition(ParserState state, String
// If the profile name includes invalid characters, it should be ignored.
if (!isValidIdentifier(profileName)) {
log.warn(() -> "Ignoring profile '" + standardizedProfileName + "' on line " + state.currentLineNumber + " because " +
"it was not alphanumeric with only these special characters: - / . % @ _");
"it was not alphanumeric with only these special characters: - / . % @ _ :");
return Optional.empty();
}

Expand Down Expand Up @@ -257,7 +257,7 @@ private static Optional<Pair<String, String>> parsePropertyDefinition(ParserStat
// If the profile name includes invalid characters, it should be ignored.
if (!isValidIdentifier(propertyKey)) {
log.warn(() -> "Ignoring property '" + propertyKey + "' on line " + state.currentLineNumber + " because " +
"its name was not alphanumeric with only these special characters: - / . % @ _");
"its name was not alphanumeric with only these special characters: - / . % @ _ :");
return Optional.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,14 @@ public void invalidPropertyNamesAreIgnored() {

@Test
public void allValidProfileNameCharactersAreSupported() {
assertThat(configFileProfiles("[profile ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_./%@]"))
.isEqualTo(profiles(profile("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_./%@")));
assertThat(configFileProfiles("[profile ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_./%@:]"))
.isEqualTo(profiles(profile("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_./%@:")));
}

@Test
public void allValidPropertyNameCharactersAreSupported() {
assertThat(configFileProfiles("[profile foo]\nABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_./%@ = value"))
.isEqualTo(profiles(profile("foo", property("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_./%@",
assertThat(configFileProfiles("[profile foo]\nABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_./%@: = value"))
.isEqualTo(profiles(profile("foo", property("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_./%@:",
"value"))));
}

Expand Down

0 comments on commit 0883321

Please sign in to comment.