Skip to content

connectionAttributes not unescaped #1463

Closed
@zhangyangyu

Description

@zhangyangyu

Issue description

Recently, connectionAttributes is supported! Currently, the value is used directly which means some special characters may lead to error, for example / which is special for this driver. If we pass %2f then it is not unescaped.

MySQL Connector/J uses a same configuration style as us. Its url parser is complex but seems finally it just decodes the whole value.

Example code

db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:4000)/test?tls=tidb&connectionAttributes=program_name:pingcap/serverless-test", user, password, host))

Error log

failed to connect databaseinvalid DSN: did you forget to escape a param value?

Configuration

Driver version (or git SHA):

Go version: run go version in your console

Server version: E.g. MySQL 5.6, MariaDB 10.0.20

Server OS: E.g. Debian 8.1 (Jessie), Windows 10

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