diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java index ff41ade15a5b..a982d7a95541 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java @@ -554,7 +554,7 @@ private void load(PropertySourceLoader loader, String location, Profile profile, private boolean hasHiddenPathElement(Resource resource) throws IOException { String cleanPath = StringUtils.cleanPath(resource.getFile().getAbsolutePath()); for (Path value : Paths.get(cleanPath)) { - if (value.toString().startsWith(".")) { + if (value.toString().startsWith("..")) { return true; } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/LocationResourceLoader.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/LocationResourceLoader.java index fbc9e33d5734..b3d232cce171 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/LocationResourceLoader.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/LocationResourceLoader.java @@ -144,7 +144,7 @@ private File getDirectory(String patternLocation, Resource resource) { } private boolean isVisibleDirectory(File file) { - return file.isDirectory() && !file.getName().startsWith("."); + return file.isDirectory() && !file.getName().startsWith(".."); } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java index 3514da78082b..fd71316ee39e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java @@ -226,7 +226,7 @@ private static boolean isPropertyFile(Path path, BasicFileAttributes attributes) private static boolean hasHiddenPathElement(Path path) { Iterator iterator = path.iterator(); while (iterator.hasNext()) { - if (iterator.next().toString().startsWith(".")) { + if (iterator.next().toString().startsWith("..")) { return true; } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/LocationResourceLoaderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/LocationResourceLoaderTests.java index 66eadf01ce8e..f93c734e6a48 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/LocationResourceLoaderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/LocationResourceLoaderTests.java @@ -129,7 +129,7 @@ void getDirectoryResourceReturnsResources() throws Exception { @Test void getResourcesWhenHasHiddenDirectoriesFiltersResults() throws IOException { createTree(); - File hiddenDirectory = new File(this.temp, ".a"); + File hiddenDirectory = new File(this.temp, "..a"); hiddenDirectory.mkdirs(); FileCopyUtils.copy("h".getBytes(), new File(hiddenDirectory, "file")); Resource[] resources = this.loader.getResources(this.temp.getAbsolutePath() + "/*/file", ResourceType.FILE); diff --git a/spring-boot-project/spring-boot/src/test/resources/config/.hidden/testproperties.properties b/spring-boot-project/spring-boot/src/test/resources/config/..hidden/testproperties.properties similarity index 100% rename from spring-boot-project/spring-boot/src/test/resources/config/.hidden/testproperties.properties rename to spring-boot-project/spring-boot/src/test/resources/config/..hidden/testproperties.properties