@@ -87,8 +87,6 @@ class ResourceProcessor implements InitializingBean, ServletContextAware {
87
87
88
88
ServletContext servletContext
89
89
90
- String rootUrlNormalized
91
-
92
90
boolean processingEnabled
93
91
94
92
List adHocIncludes
@@ -97,7 +95,6 @@ class ResourceProcessor implements InitializingBean, ServletContextAware {
97
95
List optionalDispositions
98
96
99
97
boolean resourceLocatorEnabled
100
- boolean serveUnderRootPathOnly
101
98
102
99
ConcurrentMap<String , Boolean > servingAllowedCache
103
100
ConcurrentMap<String , Boolean > resourceAllowedCache
@@ -140,10 +137,7 @@ class ResourceProcessor implements InitializingBean, ServletContextAware {
140
137
141
138
optionalDispositions = getConfigParamOrDefault(' optional.dispositions' , [' inline' , ' image' ])
142
139
143
- rootUrlNormalized = urlToNormalizedFormat(resolveUriToURL(' /' ))
144
-
145
140
resourceLocatorEnabled = getConfigParamOrDefault(' resourceLocatorEnabled' , developmentMode)
146
- serveUnderRootPathOnly = getConfigParamOrDefault(' serveUnderRootPathOnly' , (resourceLocatorEnabled== false ))
147
141
}
148
142
149
143
/**
@@ -275,20 +269,25 @@ class ResourceProcessor implements InitializingBean, ServletContextAware {
275
269
}
276
270
277
271
boolean doIsServingURLAllowed (String uri , URL url ) {
278
- if (serveUnderRootPathOnly) {
279
- String urlAsString = urlToNormalizedFormat(url)
280
- if (urlAsString== null || rootUrlNormalized == null || ! urlAsString. startsWith(rootUrlNormalized)) {
281
- return false
282
- }
283
- String relativePath = urlAsString. substring(rootUrlNormalized. length()-1 )
284
- return canProcessLegacyResource(relativePath)
285
- } else {
286
- return canProcessLegacyResource(uri)
272
+ String urlAsString = null
273
+ try {
274
+ urlAsString = urlToNormalizedFormat(url)
275
+ } catch (Exception e) {
276
+ log. warn(" uri $uri is invalid. as url $url " , e)
277
+ }
278
+
279
+ if (urlAsString== null ) {
280
+ return false
281
+ }
282
+ // only allow urls that end with the uri given as input
283
+ if (! urlAsString. endsWith(uri)) {
284
+ return false
287
285
}
286
+ return canProcessLegacyResource(uri)
288
287
}
289
288
290
289
static String urlToNormalizedFormat (URL url ) {
291
- url != null ? url. toURI(). normalize(). toASCIIString() : null
290
+ url != null ? url. toURI(). normalize() : null
292
291
}
293
292
294
293
/**
0 commit comments