Re: [BUG FIX]Connection fails with whitespace after keepalives parameter value

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, "Yuto Sasaki (Fujitsu)" <sasaki(dot)yuto-00(at)fujitsu(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [BUG FIX]Connection fails with whitespace after keepalives parameter value
Date: 2024-10-03 00:42:00
Message-ID: Zv3oWOfcrHTph7JK@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Oct 02, 2024 at 05:39:31PM -0400, Tom Lane wrote:
> Interesting. This is unhappy about the space before a parameter name,
> not the space after a parameter value, so it's a different issue.

conninfo_uri_parse_options() parses the URI as a set of option/values,
where conninfo_uri_parse_params. If we were to be careful about
trailing and leading whitespaces for the parameter names, we need to
be careful about the special JDBC cases for "ssl" and "requiressl",
meaning that we should add more logic in conninfo_uri_decode() to
discard these. That would apply a extra layer of sanity into the
values as well.

> But it's weird that ecpg takes it while libpq doesn't. Could libecpg
> be modifying/reassembling the URI string? I didn't look.

ECPGconnect() has some custom logic to discard trailing and leading
spaces:
/* Skip spaces before keyword */
for (token1 = str; *token1 == ' '; token1++)
[...]
token1[e] = '\0'; //skips trailing spaces.

The argument for libpq where we could be consistent is appealing. How
about lifting things in libpq like the attached? I wouldn't backpatch
that, but we have tests for URIs and I didn't break anything.
--
Michael

Attachment Content-Type Size
0001-libpq-Count-for-leading-and-trailing-whitespaces-in-.patch text/x-diff 2.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2024-10-03 00:53:26 Re: Pgoutput not capturing the generated columns
Previous Message Tom Lane 2024-10-03 00:30:38 Re: pg_verifybackup: TAR format backup verification