Edgewall Software

Opened 8 years ago

Closed 8 years ago

#11983 closed defect (fixed)

Cannot connect PostgreSQL database if password uses single quote characters

Reported by: Jun Omae Owned by: Jun Omae
Priority: low Milestone: 1.0.6
Component: database backend Version:
Severity: minor Keywords: postgresql
Cc: Branch:
Release Notes:

Fix wrong connection string for libpg when single quotes and/or backslashs are used in the password.

API Changes:
Internal Changes:


Trac [/dev/shm/testtest]> initenv
Database connection string [sqlite:db/trac.db]> postgres://testuser:pass%27@localhost/trac?schema=testtest

Creating and Initializing Project
Initenv for '/dev/shm/testtest' failed.
Failed to create environment.
missing "=" after "'" in connection info string

Traceback (most recent call last):
  File "/home/jun66j5/venv/trac/1.0.4/lib/python2.5/site-packages/trac/admin/console.py", line 461, in do_initenv
  File "/home/jun66j5/venv/trac/1.0.4/lib/python2.5/site-packages/trac/core.py", line 124, in __call__
    self.__init__(*args, **kwargs)
  File "/home/jun66j5/venv/trac/1.0.4/lib/python2.5/site-packages/trac/env.py", line 281, in __init__
  File "/home/jun66j5/venv/trac/1.0.4/lib/python2.5/site-packages/trac/env.py", line 601, in create
  File "/home/jun66j5/venv/trac/1.0.4/lib/python2.5/site-packages/trac/db/api.py", line 252, in init_db
  File "/home/jun66j5/venv/trac/1.0.4/lib/python2.5/site-packages/trac/db/postgres_backend.py", line 101, in init_db
  File "/home/jun66j5/venv/trac/1.0.4/lib/python2.5/site-packages/trac/db/postgres_backend.py", line 87, in get_connection
  File "/home/jun66j5/venv/trac/1.0.4/lib/python2.5/site-packages/trac/db/postgres_backend.py", line 221, in __init__
  File "/home/jun66j5/venv/py25-1.0/lib/python2.5/site-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
OperationalError: missing "=" after "'" in connection info string

According to PostgreSQL: Documentation: 8.2: Database Connection Control Functions, Single quotes and backslashes within the value must be escaped with a backslash, i.e., \' and \\.

Attachments (1)

t11983.diff (2.2 KB ) - added by Jun Omae 8 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 by Ryan J Ollos, 8 years ago

Keywords: postgresql added; postgres removed

by Jun Omae, 8 years ago

Attachment: t11983.diff added

comment:2 by Jun Omae, 8 years ago

Milestone: next-stable-1.0.x1.0.6
Owner: set to Jun Omae
Status: newassigned

Proposed changes: t11983.diff.

comment:3 by Ryan J Ollos, 8 years ago

Looks good.

comment:4 by Jun Omae, 8 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Thanks for the reviewing. Committed in [13939] and merged to trunk in [13940].

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.