diff --git a/src/main/java/com/crowdin/cli/properties/helper/FileMatcher.java b/src/main/java/com/crowdin/cli/properties/helper/FileMatcher.java index 1490ad279..9504e538d 100644 --- a/src/main/java/com/crowdin/cli/properties/helper/FileMatcher.java +++ b/src/main/java/com/crowdin/cli/properties/helper/FileMatcher.java @@ -28,6 +28,9 @@ class FileMatcher implements PathMatcher { pattern = pattern.replaceAll("/+", "/"); pattern = pattern.replaceAll("\\{\\{+", "\\\\{\\\\{"); pattern = pattern.replaceAll("}}+", "\\\\}\\\\}"); + pattern = pattern.replaceAll("\\[+", "\\\\["); + pattern = pattern.replaceAll("]+", "\\\\]"); + // We *could* implement exactly what's documented. The idea would be to implement something like // Java's Globs.toRegexPattern but supporting only the documented syntax. Instead, we will use diff --git a/src/test/java/com/crowdin/cli/properties/helper/FileHelperTest.java b/src/test/java/com/crowdin/cli/properties/helper/FileHelperTest.java index 844a3b149..6343607da 100644 --- a/src/test/java/com/crowdin/cli/properties/helper/FileHelperTest.java +++ b/src/test/java/com/crowdin/cli/properties/helper/FileHelperTest.java @@ -84,6 +84,7 @@ public void testFilterSourcesWithSpecialSymbols() { sources.add(new File("/files/folder/sub/1.xml")); sources.add(new File("/files/{{cookiecutter.module_name}}")); sources.add(new File("/files/{{cookiecutter.module_name}}/1.xml")); + sources.add(new File("/files/[folder-sub]/1.xml")); FileHelper fileHelper = new FileHelper(project.getBasePath()); List actualResult = fileHelper.filterOutIgnoredFiles(sources, Arrays.asList(".*")); assertEquals(sources, actualResult); @@ -134,4 +135,4 @@ private static List addToList(List list, E... toAdd) { toReturn.addAll(Arrays.asList(toAdd)); return toReturn; } -} \ No newline at end of file +}