Skip to content
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

Add support for : in profile names #1898

Merged
merged 3 commits into from
Jun 30, 2020
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
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