Repository navigation
PostgreSQL database names in Docker Compose JDBC URLs are not URL encoded - #52625
Merged
philwebb merged 2 commits intoNov 12, 2026
Conversation
Update `PostgresJdbcDockerComposeConnectionDetailsFactory` to URL encode PostgreSQL database names. See spring-projectsgh-52625 Signed-off-by: Raunak <raunakpandey1007@gmail.com>
philwebb
force-pushed
the
fix/postgres-docker-compose-database-encoding
branch
from
November 12, 2026 22:25
66f2289 to
da224e3
Compare
Member
|
Thanks @raunakpandey1! |
Contributor
Author
|
Glad to contribute to my favourite framework @philwebb :) |
philwebb
pushed a commit
to eatmoreduck/spring-boot
that referenced
this pull request
Nov 19, 2026
A MySQL or ClickHouse service's database name is appended to the JDBC URL without encoding. A name containing '?', '%' or other URL-significant characters is then truncated or mis-decoded by the driver. Encode it the same way as the PostgreSQL support added in spring-projects#52625, with one difference: the ClickHouse driver leaves a literal '+' untouched, so spaces are encoded as %20 rather than the x-www-form-urlencoded '+'. MariaDB is deliberately left unchanged: its driver does not percent-decode the database segment so encoding would cause a connection to a database with the wrong name. See spring-projectsgh-52817 Signed-off-by: yu.xia <yuxianice@163.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A PostgreSQL Docker Compose service with
POSTGRES_DB=my+databasecurrently gets a JDBC URL ending in/my+database. pgJDBC URL-decodes the database name, so it reads this asmy database. Names containing?,/, or literal percent escapes can likewise select a different name, alter the query parameters, or produce an invalid URL.For example, this service triggers the affected connection-details path when using Spring Boot's Docker Compose JDBC support:
Encode the database name with the existing UTF-8 URL encoder before constructing the PostgreSQL JDBC URL. The example then uses
/my%2Bdatabase, which pgJDBC reads as the originalmy+database. This follows pgJDBC's connection URL requirements and leaves the shared JDBC URL builder unchanged.The regression test passes generated connection URLs through pgJDBC's actual
Driver.parseURL, covering reserved characters, literal percent escapes, spaces, and Unicode, while also checking that the explicit connection parameters and automatic application name survive.Validation on current
main(c1eb7d54a7149da16bc5d632d7464dba3b11b88e, 4.2.0-SNAPSHOT), Temurin JDK 25.0.5, pgJDBC 42.7.14::module:spring-boot-jdbc:checkFormat,checkstyleMain, andcheckstyleTestpassed;git diff --checkpassed.