Skip to content

Commit 1eaa4c4

Browse files
brunoborgesCopilot
andcommitted
Fix YAML parsing on Windows: read as string before parsing
Jackson's UTF8Reader has a buffer boundary bug with multi-byte UTF-8 characters (e.g., French accents) at the 1024-byte mark on Windows. Replace readTree(File) with readTree(Files.readString(path)) to use Java's own UTF-8 decoding instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5c9d966 commit 1eaa4c4

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

html-generators/generate.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ static Optional<Path> findWithExtensions(Path dir, String baseName) {
8989
static JsonNode readAuto(Path path) throws IOException {
9090
var name = path.getFileName().toString();
9191
var ext = name.substring(name.lastIndexOf('.') + 1);
92-
return MAPPERS.getOrDefault(ext, JSON_MAPPER).readTree(path.toFile());
92+
var content = Files.readString(path);
93+
return MAPPERS.getOrDefault(ext, JSON_MAPPER).readTree(content);
9394
}
9495

9596
/** Load UI strings for a locale, falling back to en.json for missing keys */
@@ -297,7 +298,7 @@ SequencedMap<String, Snippet> loadAllSnippets() throws IOException {
297298
for (var path : sorted) {
298299
var filename = path.getFileName().toString();
299300
var ext = filename.substring(filename.lastIndexOf('.') + 1);
300-
var json = MAPPERS.get(ext).readTree(path.toFile());
301+
var json = MAPPERS.get(ext).readTree(Files.readString(path));
301302
var snippet = new Snippet(json);
302303
snippets.put(snippet.key(), snippet);
303304
}

html-generators/generateog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ SequencedMap<String, Snippet> loadAllSnippets() throws IOException {
192192
for (var path : sorted) {
193193
var ext = path.getFileName().toString();
194194
ext = ext.substring(ext.lastIndexOf('.') + 1);
195-
var snippet = new Snippet(MAPPERS.get(ext).readTree(path.toFile()));
195+
var snippet = new Snippet(MAPPERS.get(ext).readTree(Files.readString(path)));
196196
snippets.put(snippet.key(), snippet);
197197
}
198198
}

0 commit comments

Comments
 (0)