Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i46d8-0004k3-AU for pgsql-general@arkaria.postgresql.org; Sat, 31 Aug 2019 16:53:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i46d6-0002si-UA for pgsql-general@arkaria.postgresql.org; Sat, 31 Aug 2019 16:53:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i46d6-0002sb-Hp for pgsql-general@lists.postgresql.org; Sat, 31 Aug 2019 16:53:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i46cz-0004kI-Pk for pgsql-general@postgresql.org; Sat, 31 Aug 2019 16:53:35 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x7VGqxU4012242; Sat, 31 Aug 2019 12:52:59 -0400 From: Tom Lane To: Luca Ferrari cc: "Egashira, Yusuke" , Alban Hertroys , "pgsql-general@postgresql.org" , Adrian Klaver , Giuseppe Sacco Subject: Re: Question about password character in ECPG's connection string In-reply-to: References: <848B1649C8A6274AA527C4472CA11EDD5FC70CBE@G01JPEXMBYT02> <848B1649C8A6274AA527C4472CA11EDD5FC76A28@G01JPEXMBYT02> <1B0DE6CA-7E1F-4AB8-B6D5-D486FEFDD786@gmail.com> <848B1649C8A6274AA527C4472CA11EDD5FC78613@G01JPEXMBYT02> Comments: In-reply-to Luca Ferrari message dated "Thu, 29 Aug 2019 13:34:23 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <12240.1567270379.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 31 Aug 2019 12:52:59 -0400 Message-ID: <12241.1567270379@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Luca Ferrari writes: > On Thu, Aug 29, 2019 at 1:08 PM Egashira, Yusuke > 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 characte= rs. > As far as I understand from > > unwanted characters are '&' and '=3D'. 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=3Dvalue[&keyword=3Dvalue...] 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 '=3D' in a keyword (which is moot because none of them have '=3D') 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