diff --git a/changes.xml b/changes.xml index 9e55499b..8701e033 100644 --- a/changes.xml +++ b/changes.xml @@ -23,6 +23,12 @@ xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 https://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd"> + + + Special handling for detecting ".cfg.json" file extensions. + + + Increase SnakeYAML codepoint limit to 64MB (from default 3MB). diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/util/FileUtil.java b/generator/src/main/java/io/wcm/devops/conga/generator/util/FileUtil.java index 6c447d30..0e7d9dd5 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/util/FileUtil.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/util/FileUtil.java @@ -110,7 +110,16 @@ public static boolean matchesExtension(String fileExtension, String extension) { * @return true if file extension matches */ public static boolean matchesExtension(File file, String extension) { - return matchesExtension(FilenameUtils.getExtension(file.getName()), extension); + String fileName = file.getName(); + String fileExtension; + // special handling for OSGi configuration resource file extension + if (fileName.endsWith(".cfg.json")) { + fileExtension = "cfg.json"; + } + else { + fileExtension = FilenameUtils.getExtension(fileName); + } + return matchesExtension(fileExtension, extension); } /** diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/util/FileUtilTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/util/FileUtilTest.java new file mode 100644 index 00000000..7b0b67c1 --- /dev/null +++ b/generator/src/test/java/io/wcm/devops/conga/generator/util/FileUtilTest.java @@ -0,0 +1,41 @@ +/* + * #%L + * wcm.io + * %% + * Copyright (C) 2024 wcm.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package io.wcm.devops.conga.generator.util; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.File; + +import org.junit.jupiter.api.Test; + +class FileUtilTest { + + @Test + void testMatchesExtension() { + assertTrue(FileUtil.matchesExtension(new File("test.txt"), "txt")); + assertTrue(FileUtil.matchesExtension(new File("test.part2.txt"), "txt")); + assertFalse(FileUtil.matchesExtension(new File("test.pdf"), "txt")); + + // special handling for OSGi configuration resource file extension + assertTrue(FileUtil.matchesExtension(new File("test.cfg.json"), "cfg.json")); + } + +}