Re: [BUG FIX]Connection fails with whitespace after keepalives parameter value
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>, "Yuto Sasaki (Fujitsu)" <sasaki.yuto-00@fujitsu.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2024-10-03T00:42:00Z
Lists: pgsql-hackers
Attachments
- 0001-libpq-Count-for-leading-and-trailing-whitespaces-in-.patch (text/x-diff) patch 0001
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
Commits
-
libpq: Discard leading and trailing spaces for parameters and values in URIs
- 430ce189fc45 18.0 landed
-
ecpg: avoid adding whitespace around '&' in connection URLs.
- f22e84df1dea 18.0 landed
-
Parse libpq's "keepalives" option more like other integer options.
- e7af9b52f679 14.14 landed
- c7a201053e3f 17.1 landed
- bb8c89dbcde7 15.9 landed
- 920d51979a99 18.0 landed
- 65f431affda8 16.5 landed
- 47d8a15deaeb 12.21 landed
- 2120eda94420 13.17 landed