From 08833212836f6958364e0c0bb8abd1d0e6440c8c Mon Sep 17 00:00:00 2001 From: Lee Packham <9469+leepa@users.noreply.github.com> Date: Mon, 15 Jun 2020 13:50:57 +0100 Subject: [PATCH] Add support for : in profile names --- .../awssdk/profiles/internal/ProfileFileReader.java | 6 +++--- .../software/amazon/awssdk/profiles/ProfileFileTest.java | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/profiles/src/main/java/software/amazon/awssdk/profiles/internal/ProfileFileReader.java b/core/profiles/src/main/java/software/amazon/awssdk/profiles/internal/ProfileFileReader.java index f111df7b2413..c62ca7a15ce7 100644 --- a/core/profiles/src/main/java/software/amazon/awssdk/profiles/internal/ProfileFileReader.java +++ b/core/profiles/src/main/java/software/amazon/awssdk/profiles/internal/ProfileFileReader.java @@ -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() { } @@ -214,7 +214,7 @@ private static Optional 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(); } @@ -257,7 +257,7 @@ private static Optional> 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(); } diff --git a/core/profiles/src/test/java/software/amazon/awssdk/profiles/ProfileFileTest.java b/core/profiles/src/test/java/software/amazon/awssdk/profiles/ProfileFileTest.java index d39126d60206..82377ae6c6aa 100644 --- a/core/profiles/src/test/java/software/amazon/awssdk/profiles/ProfileFileTest.java +++ b/core/profiles/src/test/java/software/amazon/awssdk/profiles/ProfileFileTest.java @@ -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")))); }