From: Tom Lane <tgl@sss.pgh.pa.us>
To: Luca Ferrari <fluca1978@gmail.com>
Cc: Egashira, Yusuke <egashira.yusuke@jp.fujitsu.com>
Cc: Alban Hertroys <haramrae@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org>
Subject: Re: Question about password character in ECPG's connection string
Date: Sat, 31 Aug 2019 12:52:59 -0400
Message-ID: <12241.1567270379@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKoxK+5fRS3y4XTkEgmU7zDME7cXg0doX8O6w2BWDP6X06RJpg@mail.gmail.com>
References: <848B1649C8A6274AA527C4472CA11EDD5FC70CBE@G01JPEXMBYT02>
<edb3a9df78da4afe744afd7aacd3684ea96dc394.camel@eppesuigoccas.homedns.org>
<848B1649C8A6274AA527C4472CA11EDD5FC76A28@G01JPEXMBYT02>
<d9b3700d-40bd-1229-2e26-167fafab5c8a@aklaver.com>
<1B0DE6CA-7E1F-4AB8-B6D5-D486FEFDD786@gmail.com>
<CAKoxK+7K0x_U-jHbJEajNFL=kfnoLT+W30sJOK3dtwnLGa9kYQ@mail.gmail.com>
<848B1649C8A6274AA527C4472CA11EDD5FC78613@G01JPEXMBYT02>
<CAKoxK+5fRS3y4XTkEgmU7zDME7cXg0doX8O6w2BWDP6X06RJpg@mail.gmail.com>
Luca Ferrari <fluca1978@gmail.com> writes:
> On Thu, Aug 29, 2019 at 1:08 PM Egashira, Yusuke
> <egashira.yusuke@jp.fujitsu.com> wrote:
>> According to my tests, I think that the ECPG's connection_option seems not to accept '&' character as password anyhow...
>> ECPG CONNECT's connection_option seems to have some restricted characters.
> As far as I understand from
> <https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/interfaces/ecpg/ecpglib/connect.c;h...;
> unwanted characters are '&' and '='. Even if the connetion string
> seems an URL, it is managed in plain text without any sort of
> escaping.
Yeah, the format of the "options" string is not mentioned at all in the
ECPG documentation, but from looking at the code, it's
keyword=value[&keyword=value...]
where the keywords are the same option keywords recognized by
PQconnectdbParams. Also, you can write spaces just before
(but not after) any keyword or value.
Given this, you can't write '=' in a keyword (which is moot because
none of them have '=') and you can't write '&' in a value.
Note that the ECPG documentation does not suggest that you can set
either username or password this way. I'm inclined to think that it's
a bad idea to do so, even if it seems to work. At minimum it'd mean
that ecpglib has the wrong idea of what the connection's username is,
which seems likely to bite people someday.
If you're not trying to game the system like that, the set of
characters you might actually need in a value seems fairly
constrained, so the restriction about '&' doesn't seem like a huge
problem. If we introduced URI-style escaping, we'd just make the
problem of funny characters worse, because then '%' would also become
magic. An alternative that doesn't risk breaking cases that work
today is to say that you can write '&&' to mean a literal '&', but
that seems kind of icky; there's nothing else that does that.
On the whole I'm content with the way the code works now, but we do
need to document it.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, fluca1978@gmail.com, egashira.yusuke@jp.fujitsu.com, haramrae@gmail.com, adrian.klaver@aklaver.com, giuseppe@eppesuigoccas.homedns.org
Subject: Re: Question about password character in ECPG's connection string
In-Reply-To: <12241.1567270379@sss.pgh.pa.us>
References: <848B1649C8A6274AA527C4472CA11EDD5FC70CBE@G01JPEXMBYT02> <edb3a9df78da4afe744afd7aacd3684ea96dc394.camel@eppesuigoccas.homedns.org> <848B1649C8A6274AA527C4472CA11EDD5FC76A28@G01JPEXMBYT02> <d9b3700d-40bd-1229-2e26-167fafab5c8a@aklaver.com> <1B0DE6CA-7E1F-4AB8-B6D5-D486FEFDD786@gmail.com> <CAKoxK+7K0x_U-jHbJEajNFL=kfnoLT+W30sJOK3dtwnLGa9kYQ@mail.gmail.com> <848B1649C8A6274AA527C4472CA11EDD5FC78613@G01JPEXMBYT02> <CAKoxK+5fRS3y4XTkEgmU7zDME7cXg0doX8O6w2BWDP6X06RJpg@mail.gmail.com> <12241.1567270379@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox