Merge branch 'fvanderveen-jetty-9.3.x' into jetty-9.3.x

This commit is contained in:
Joakim Erdfelt 2017-03-31 11:20:20 -07:00
commit d1c946d192
2 changed files with 28 additions and 3 deletions

View File

@ -73,7 +73,17 @@ public class PathResource extends Resource
if(!URIUtil.equalsIgnoreEncodings(uri,path.toUri()))
{
return new File(uri).toPath().toAbsolutePath();
try
{
return Paths.get(uri).toRealPath(FOLLOW_LINKS);
}
catch (IOException ignored)
{
// If the toRealPath() call fails, then let
// the alias checking routines continue on
// to other techniques.
LOG.ignore(ignored);
}
}
if (!abs.isAbsolute())
@ -568,4 +578,4 @@ public class PathResource extends Resource
{
return this.uri.toASCIIString();
}
}
}

View File

@ -29,6 +29,7 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeNoException;
import static org.junit.Assume.assumeThat;
import static org.junit.Assume.assumeTrue;
import java.io.BufferedWriter;
import java.io.File;
@ -1397,5 +1398,19 @@ public class FileSystemResourceTest
}
}
@Test
public void testUncPath() throws Exception
{
assumeTrue("Only windows supports UNC paths", OS.IS_WINDOWS);
assumeFalse("FileResource does not support this test", _class.equals(FileResource.class));
try (Resource base = newResource(URI.create("file://127.0.0.1/path")))
{
Resource resource = base.addPath("WEB-INF/");
assertThat("getURI()", resource.getURI().toASCIIString(), containsString("path/WEB-INF/"));
assertThat("isAlias()", resource.isAlias(), is(true));
assertThat("getAlias()", resource.getAlias(), notNullValue());
assertThat("getAlias()", resource.getAlias().toASCIIString(), containsString("path/WEB-INF"));
}
}
}