Skip to content

Commit

Permalink
fix (core): Make *.jsonld have UTF-8 encoding by default
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Apr 15, 2024
1 parent 79e4d3d commit e3e2100
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,15 @@ public MediaType detect(String contentType, String contentEncoding, URI uri) {
if (mediaType.is(MediaType.ANY_TEXT_TYPE)) {
// TODO Remove this; it's wrong! Generic text cannot just be assumed to be UTF-8!
mediaType = mediaType.withCharset(Charsets.UTF_8);
// TODO This should move into a TBD JsonMediaType implements ResourceCharsetDetector
} else if (mediaType.is(MediaType.JSON_UTF_8.withoutParameters())) {
// TODO See ResourceCharsetDetector above; implement JSON BOM detection à la §3 from
// https://www.ietf.org/rfc/rfc4627.txt in a new class JsonResourceCharsetDetector
mediaType = mediaType.withCharset(Charsets.UTF_8);
} else if (mediaType.subtype().endsWith("+json")) {
mediaType = mediaType.withCharset(Charsets.UTF_8);
}
// TODO NOT if (mediaType.subtype().endsWith("+yaml")) { but via YamlMediaType
}

return mediaType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
public class YamlMediaType extends ResourceCharsetDetectorSPI implements MediaTypeProvider {
// TODO Move this into e.g. dev.enola.format.yaml ?

// TODO How to allow this to express mediaType.subtype().endsWith("+yaml") ?

// https://www.ietf.org/archive/id/draft-ietf-httpapi-yaml-mediatypes-00.html
// https://github.com/ietf-wg-httpapi/mediatypes/blob/main/draft-ietf-httpapi-yaml-mediatypes.md

Expand Down

0 comments on commit e3e2100

Please sign in to comment.