From 557385ea61dfb9d2c2dfab536f5fc3911e7bfd54 Mon Sep 17 00:00:00 2001 From: Scott Babcock Date: Wed, 21 Nov 2018 00:53:45 -0800 Subject: [PATCH] Add quoting of path base name --- src/main/java/com/nordstrom/common/file/PathUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/nordstrom/common/file/PathUtils.java b/src/main/java/com/nordstrom/common/file/PathUtils.java index 98150e9..bd8e49b 100644 --- a/src/main/java/com/nordstrom/common/file/PathUtils.java +++ b/src/main/java/com/nordstrom/common/file/PathUtils.java @@ -168,7 +168,7 @@ public static Path getNextPath(Path targetPath, String baseName, String extensio throw new IllegalArgumentException("[extension] must specify a non-empty string"); } - PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher("regex:" + baseName + "(-\\d+)?\\." + extension); + PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher("regex:\\Q" + baseName + "\\E(-\\d+)?\\." + extension); try (Stream stream = Files.walk(targetPath, 1)) { int base = baseName.length();