From 62aa1b7aaf24194ce46158b3ef7ece63f6d05ea7 Mon Sep 17 00:00:00 2001 From: Scott Frederick Date: Wed, 4 Nov 2020 16:09:54 -0600 Subject: [PATCH] Narrow criteria for hidden property paths A previous change intended to prevent temporary directories created as an implementation detail of mounting volumes on kubernetes pods from being used as a source for property files had a side-effect of also preventing other types of hidden directories from being recognized. This commit narrows the criteria for considering a directory as hidden, using the kubernetes `..` prefix convention instead of the Unix `.` prefix. Fixes gh-23983 --- .../boot/context/config/ConfigFileApplicationListener.java | 2 +- .../config/{.hidden => ..hidden}/testproperties.properties | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename spring-boot-project/spring-boot/src/test/resources/config/{.hidden => ..hidden}/testproperties.properties (100%) 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 c08d51c6aea6..0cf0b0a8825b 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 @@ -569,7 +569,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/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