Skip to content

Can still successfully connect to the database with a password that contains Spaces #2000

@cangwuwuwu

Description

@cangwuwuwu

I'm submitting a ...

  • bug report
  • feature request

Describe the issue
My postgresql version is 13.1 and my password is 'postgres' ,when I input password like 'post gres'(contains spaces),I can still successfully connect to the DB.
This is the same result When I use the Springboot DataSource.

Driver Version?
42.2.18

Java Version?
1.8.0_271

OS Version?
CentOS7/MacOSX

PostgreSQL Version?
PostgreSQL 13.1

To Reproduce
Steps to reproduce the behaviour:

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.2.18</version>
</dependency>
import java.sql.Driver;
import java.sql.DriverManager;
import java.util.Properties;

public class PostgreSQLJDBC {
    public static void main(String[] args) {
        String url = "jdbc:postgresql://localhost:5432/miemuch";
        try {
            Class.forName("org.postgresql.Driver");
            Driver driver = DriverManager.getDriver(url);
            Properties driverProperties = new Properties();
            final Properties cloned = (Properties) driverProperties.clone();
            cloned.put("user", "postgres");
            cloned.put("password", "postgre s");
            driver.connect(url, cloned);
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Expected behaviour
This should not succeed in connecting to the database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions