fix(appconfig): accept a quoted Ion type parameter in Accept (#5687)

GetLatestConfiguration and the legacy GetConfiguration compared the
type parameter of an Accept media range verbatim, quotes included. So
application/ion with type="AWS.AppConfig.FeatureFlags" did not match,
and a feature flag profile with variants came back as the stored JSON
instead of Ion. RFC 9110 section 5.6.6 makes a quoted-string parameter
value the same value as its token form.

The type value is now read as a token, or as a quoted-string without
its DQUOTEs and with each quoted-pair standing for the character after
its backslash (section 5.6.4). A quoted-string that is not closed, or
that has text after its closing DQUOTE, does not match. The media range
and the q weight are read as before.

Closes #5673

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
This commit is contained in:
Jackson Price authored and GitHub committed 2026-10-14 20:48:24 -04:00
1 parent 503899df05
commit 190ed52249
4 files changed
+152 -4

No files matched your search

@@ -225,7 +225,7 @@ public class AppConfigDataService {
String name = parameter[0].trim();
String value = parameter[1].trim();
if (name.equalsIgnoreCase("type")) {
featureFlags = "AWS.AppConfig.FeatureFlags".equalsIgnoreCase(value);
featureFlags = "AWS.AppConfig.FeatureFlags".equalsIgnoreCase(parameterValue(value));
} else if (name.equalsIgnoreCase("q")) {
acceptable = !value.matches("0(\\.0+)?");
}
@@ -237,6 +237,33 @@ public class AppConfigDataService {
return false;
}
/**
* A media-type parameter value as RFC 9110 section 5.6.6 defines it: a token as is, or a quoted-string without its
* DQUOTEs and with each quoted-pair read as the character after its backslash (section 5.6.4). {@code null} for a
* quoted-string with no closing DQUOTE or with anything after it.
*/
private static String parameterValue(String value) {
if (!value.startsWith("\"")) {
return value;
}
StringBuilder unquoted = new StringBuilder();
boolean escaped = false;
for (int i = 1; i < value.length(); i++) {
char c = value.charAt(i);
if (escaped) {
unquoted.append(c);
escaped = false;
} else if (c == '\\') {
escaped = true;
} else if (c == '"') {
return i == value.length() - 1 ? unquoted.toString() : null;
} else {
unquoted.append(c);
}
}
return null;
}
static byte[] transformFeatureFlags(byte[] content, ObjectMapper objectMapper) {
if (content == null || content.length == 0) {
return content;