Browse Source

Merge pull request #4766 from mbenson/issue-4765

* pr/4766:
  Use canonical paths for Undertow document root
pull/4760/merge
Phillip Webb 10 years ago
parent
commit
da50eb9ab2
  1. 19
      spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java

19
spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java

@ -427,8 +427,7 @@ public class UndertowEmbeddedServletContainerFactory @@ -427,8 +427,7 @@ public class UndertowEmbeddedServletContainerFactory
}
private ResourceManager getDocumentRootResourceManager() {
File root = getValidDocumentRoot();
root = (root != null ? root : createTempDir("undertow-docbase"));
File root = getCanonicalDocumentRoot();
if (root.isDirectory()) {
return new FileResourceManager(root, 0);
}
@ -438,6 +437,22 @@ public class UndertowEmbeddedServletContainerFactory @@ -438,6 +437,22 @@ public class UndertowEmbeddedServletContainerFactory
return ResourceManager.EMPTY_RESOURCE_MANAGER;
}
/**
* Return the document root in canonical form. Undertow uses File#getCanonicalFile()
* to determine whether a resource has been requested using the proper case but on
* Windows {@code java.io.tmpdir} may be set as a tilde-compressed pathname.
*/
private File getCanonicalDocumentRoot() {
try {
File root = getValidDocumentRoot();
root = (root != null ? root : createTempDir("undertow-docbase"));
return root.getCanonicalFile();
}
catch (IOException e) {
throw new IllegalStateException("Cannot get canonical document root", e);
}
}
private void configureErrorPages(DeploymentInfo servletBuilder) {
for (ErrorPage errorPage : getErrorPages()) {
servletBuilder.addErrorPage(getUndertowErrorPage(errorPage));

Loading…
Cancel
Save