Skip to content
Open
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
17 changes: 17 additions & 0 deletions src/workerd/util/mimetype-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,23 @@ KJ_TEST("Quoted-string escape handling") {
}
}

KJ_TEST("AWS JSON MIME types are classified as text") {
static constexpr kj::StringPtr supportedTypes[] = {
"application/x-amz-json-1.0"_kj,
"application/x-amz-json-1.1"_kj,
};

for (const auto& input: supportedTypes) {
auto mimeType = KJ_ASSERT_NONNULL(MimeType::tryParse(input));
KJ_ASSERT(MimeType::isText(mimeType));
KJ_ASSERT(!MimeType::isJson(mimeType));
}

auto unsupportedType = KJ_ASSERT_NONNULL(MimeType::tryParse("application/x-amz-json-1.2"_kj));
KJ_ASSERT(!MimeType::isText(unsupportedType));
KJ_ASSERT(!MimeType::isJson(unsupportedType));
}

KJ_TEST("Backslash escaping in serialization round-trips") {
// A value containing both backslash and non-token chars must be quoted
// with the backslash escaped, and the result must round-trip.
Expand Down
3 changes: 2 additions & 1 deletion src/workerd/util/mimetype.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ class MimeType final {
auto type = mimeType.type();
auto subtype = mimeType.subtype();
return type == "text" || isXml(mimeType) || isJson(mimeType) || isJavascript(mimeType) ||
(type == "application" && subtype == "dns-json");
(type == "application" &&
(subtype == "dns-json" || subtype == "x-amz-json-1.0" || subtype == "x-amz-json-1.1"));
}

template <IsMimeType T>
Expand Down
Loading