Skip to content

Commit

Permalink
Merge pull request #4 from AlexisJehan/3-coments-are-not-allowed-beca…
Browse files Browse the repository at this point in the history
…use-of-artifactfilterparseexception

Fix the UTF-8 with BOM encoding compatibility for ignore files
  • Loading branch information
AlexisJehan authored Aug 29, 2024
2 parents 304563b + 8d5c1b3 commit 81d6b4d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public static ArtifactFilter parse(final Path ignoreFile) throws IOException {
Ensure.notNullAndFile("ignoreFile", ignoreFile);
logger.info("Parsing the {} ignore file", () -> ToString.toString(ignoreFile));
try (var reader = Readers.of(ignoreFile)) {
reader.mark(1);
if ('\ufeff' != reader.read()) { // UTF-8 BOM character
reader.reset();
}
return parse(reader);
} catch (final ArtifactFilterParseException e) {
throw e.with(ignoreFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ void testParsePath() {
assertThatNoException().isThrownBy(
() -> ArtifactFilterParser.parse(Path.of("src", "test", "resources", ".mvnchk-ignore_foo"))
);
assertThatNoException().isThrownBy(
() -> ArtifactFilterParser.parse(Path.of("src", "test", "resources", ".mvnchk-ignore_bom"))
);
}

@Test
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/.mvnchk-ignore_bom
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# comment

0 comments on commit 81d6b4d

Please sign in to comment.