Skip to content

Commit 5d57243

Browse files
committed
Hibernate Dev UI: Fix allowed jdbc url with ;
1 parent 208a869 commit 5d57243

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

extensions/hibernate-orm/runtime-dev/src/main/java/io/quarkus/hibernate/orm/dev/ui/HibernateOrmDevJsonRpcService.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -305,23 +305,25 @@ private boolean isAllowedDatabase(AgroalDataSource ads) {
305305
return true;
306306
}
307307

308+
if (ads == null)
309+
return false;
310+
308311
AgroalDataSourceConfiguration configuration = ads.getConfiguration();
309312
String jdbcUrl = configuration.connectionPoolConfiguration().connectionFactoryConfiguration().jdbcUrl();
310313

311-
try {
312-
if (jdbcUrl.startsWith("jdbc:h2:mem:") || jdbcUrl.startsWith("jdbc:h2:file:")
313-
|| jdbcUrl.startsWith("jdbc:h2:tcp://localhost")
314-
|| (allowedHost != null && !allowedHost.isBlank()
315-
&& jdbcUrl.startsWith("jdbc:h2:tcp://" + allowedHost))
316-
|| jdbcUrl.startsWith("jdbc:derby:memory:")) {
317-
return true;
318-
}
314+
if (jdbcUrl.startsWith("jdbc:h2:mem:") || jdbcUrl.startsWith("jdbc:h2:file:")
315+
|| jdbcUrl.startsWith("jdbc:h2:tcp://localhost")
316+
|| (allowedHost != null && !allowedHost.isBlank()
317+
&& jdbcUrl.startsWith("jdbc:h2:tcp://" + allowedHost))
318+
|| jdbcUrl.startsWith("jdbc:derby:memory:")) {
319+
return true;
320+
}
319321

320-
String cleanUrl = jdbcUrl.replace("jdbc:", "");
321-
URI uri = new URI(cleanUrl);
322+
String cleanUrl = jdbcUrl.replace("jdbc:", "").replaceFirst(";", "?").replace(";", "&");
322323

324+
try {
325+
URI uri = new URI(cleanUrl);
323326
String host = uri.getHost();
324-
325327
return host != null && ((host.equals("localhost") || host.equals("127.0.0.1") || host.equals("::1")) ||
326328
(allowedHost != null && !allowedHost.isBlank() && host.equalsIgnoreCase(allowedHost)));
327329

0 commit comments

Comments
 (0)