提交 403ff5cb authored 作者: Thomas Mueller's avatar Thomas Mueller

Server: it was possible to open a database outside of the base URL (if one was…

Server: it was possible to open a database outside of the base URL (if one was set). The test case was broken.
上级 e3d97902
......@@ -147,9 +147,9 @@ public class ConnectionInfo implements Cloneable {
prefix = name.substring(0, name.length() - n.length());
n = dir + SysProperties.FILE_SEPARATOR + n;
}
String absName = IOUtils.unwrap(IOUtils.getAbsolutePath(n));
if (absName.equals(absDir) || !absName.startsWith(absDir)) {
throw DbException.get(ErrorCode.IO_EXCEPTION_1, absName + " outside " +
String normalizedName = IOUtils.unwrap(IOUtils.normalize(n));
if (normalizedName.equals(absDir) || !normalizedName.startsWith(absDir)) {
throw DbException.get(ErrorCode.IO_EXCEPTION_1, normalizedName + " outside " +
absDir);
}
if (!absolute) {
......
......@@ -73,7 +73,6 @@ public class TestTools extends TestBase {
return;
}
org.h2.Driver.load();
testInMemoryBaseDir();
testConsole();
testJdbcDriverUtils();
testWrongServer();
......@@ -844,31 +843,12 @@ public class TestTools extends TestBase {
try {
DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/../test", "sa", "");
fail("Should throw an exception!");
} catch (Throwable e) {
// Expected
} catch (SQLException e) {
assertKnownException(e);
}
server.stop();
deleteDb("testSplit");
}
private void testInMemoryBaseDir() throws SQLException {
Connection conn;
Server tcpServer = Server.createTcpServer(
"-baseDir", "memFS:/testDir",
"-tcpPort", "9192",
"-tcpAllowOthers").start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", "sa", "");
conn.close();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/split:test", "sa", "");
conn.close();
try {
DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/split:../test", "sa", "");
fail("Should throw an exception!");
} catch (Throwable e) {
// Expected
}
tcpServer.stop();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论