|
18 | 18 |
|
19 | 19 | import java.io.File;
|
20 | 20 | import java.io.IOException;
|
21 |
| -import java.net.MalformedURLException; |
22 | 21 | import java.net.URL;
|
| 22 | +import java.net.URLEncoder; |
23 | 23 | import java.time.Duration;
|
24 | 24 | import java.util.ArrayList;
|
25 | 25 | import java.util.Arrays;
|
|
33 | 33 | import java.util.Map;
|
34 | 34 | import java.util.Set;
|
35 | 35 | import java.util.concurrent.TimeUnit;
|
| 36 | +import java.util.regex.Pattern; |
36 | 37 |
|
37 | 38 | import javax.servlet.ServletContainerInitializer;
|
38 | 39 | import javax.servlet.ServletContext;
|
|
95 | 96 | public class UndertowServletWebServerFactory extends AbstractServletWebServerFactory
|
96 | 97 | implements ConfigurableUndertowWebServerFactory, ResourceLoaderAware {
|
97 | 98 |
|
| 99 | + private static final Pattern ENCODED_SLASH = Pattern.compile("%2F", Pattern.LITERAL); |
| 100 | + |
98 | 101 | private static final Set<Class<?>> NO_CLASSES = Collections.emptySet();
|
99 | 102 |
|
100 | 103 | private Set<UndertowBuilderCustomizer> builderCustomizers = new LinkedHashSet<>();
|
@@ -583,14 +586,15 @@ public void removeResourceChangeListener(ResourceChangeListener listener) {
|
583 | 586 |
|
584 | 587 | private URLResource getMetaInfResource(URL resourceJar, String path) {
|
585 | 588 | try {
|
586 |
| - URL resourceUrl = new URL(resourceJar + "META-INF/resources" + path); |
| 589 | + String urlPath = URLEncoder.encode(ENCODED_SLASH.matcher(path).replaceAll("/"), "UTF-8"); |
| 590 | + URL resourceUrl = new URL(resourceJar + "META-INF/resources" + urlPath); |
587 | 591 | URLResource resource = new URLResource(resourceUrl, path);
|
588 | 592 | if (resource.getContentLength() < 0) {
|
589 | 593 | return null;
|
590 | 594 | }
|
591 | 595 | return resource;
|
592 | 596 | }
|
593 |
| - catch (MalformedURLException ex) { |
| 597 | + catch (Exception ex) { |
594 | 598 | return null;
|
595 | 599 | }
|
596 | 600 | }
|
|
0 commit comments