From 695bf2961feffd35b5560ccc982a2189dcca611f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 29 Mar 2018 16:04:33 +0200 Subject: [PATCH] Consistent trace logging in PathResourceResolver Issue: SPR-16616 --- .../web/reactive/resource/PathResourceResolver.java | 10 +++++----- .../web/servlet/resource/PathResourceResolver.java | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/PathResourceResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/PathResourceResolver.java index 404607542d..1f49cde6cb 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/PathResourceResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/PathResourceResolver.java @@ -118,10 +118,10 @@ public class PathResourceResolver extends AbstractResourceResolver { } else if (logger.isTraceEnabled()) { Resource[] allowedLocations = getAllowedLocations(); - logger.trace("Resource path=\"" + resourcePath + "\" was successfully resolved " + - "but resource=\"" + resource.getURL() + "\" is neither under the " + - "current location=\"" + location.getURL() + "\" nor under any of the " + - "allowed locations=" + (allowedLocations != null ? Arrays.asList(allowedLocations) : "[]")); + logger.trace("Resource path \"" + resourcePath + "\" was successfully resolved " + + "but resource \"" + resource.getURL() + "\" is neither under the " + + "current location \"" + location.getURL() + "\" nor under any of the " + + "allowed locations " + (allowedLocations != null ? Arrays.asList(allowedLocations) : "[]")); } } else if (logger.isTraceEnabled()) { @@ -195,7 +195,7 @@ public class PathResourceResolver extends AbstractResourceResolver { String decodedPath = URLDecoder.decode(resourcePath, "UTF-8"); if (decodedPath.contains("../") || decodedPath.contains("..\\")) { if (logger.isTraceEnabled()) { - logger.trace("Ignoring invalid resource path with escape sequences [" + resourcePath + "]"); + logger.trace("Resolved resource path contains encoded \"../\" or \"..\\\": " + resourcePath); } return true; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PathResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PathResourceResolver.java index 43a8397650..13de12e493 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PathResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PathResourceResolver.java @@ -189,10 +189,10 @@ public class PathResourceResolver extends AbstractResourceResolver { } else if (logger.isTraceEnabled()) { Resource[] allowedLocations = getAllowedLocations(); - logger.trace("Resource path=\"" + resourcePath + "\" was successfully resolved " + - "but resource=\"" + resource.getURL() + "\" is neither under the " + - "current location=\"" + location.getURL() + "\" nor under any of the " + - "allowed locations=" + (allowedLocations != null ? Arrays.asList(allowedLocations) : "[]")); + logger.trace("Resource path \"" + resourcePath + "\" was successfully resolved " + + "but resource \"" + resource.getURL() + "\" is neither under the " + + "current location \"" + location.getURL() + "\" nor under any of the " + + "allowed locations " + (allowedLocations != null ? Arrays.asList(allowedLocations) : "[]")); } } return null; @@ -286,7 +286,7 @@ public class PathResourceResolver extends AbstractResourceResolver { String decodedPath = URLDecoder.decode(resourcePath, "UTF-8"); if (decodedPath.contains("../") || decodedPath.contains("..\\")) { if (logger.isTraceEnabled()) { - logger.trace("Ignoring invalid resource path with escape sequences [" + resourcePath + "]"); + logger.trace("Resolved resource path contains encoded \"../\" or \"..\\\": " + resourcePath); } return true; }