libpq: Discard leading and trailing spaces for parameters and values in URIs
authorMichael Paquier <michael@paquier.xyz>
Sun, 6 Oct 2024 09:23:02 +0000 (18:23 +0900)
committerMichael Paquier <michael@paquier.xyz>
Sun, 6 Oct 2024 09:23:02 +0000 (18:23 +0900)
commit430ce189fc4521a1c197eee36b8ca6b37b29e86e
treec9b5193ed86c46faf4c6754e6a36e9854f80d4d7
parent68dfecbef210dc000271553cfcb2342989d4ca0f
libpq: Discard leading and trailing spaces for parameters and values in URIs

Integer values applied a parsing rule through pqParseIntParam() that
made URIs like this one working, even if these include spaces around
values:
"postgresql://localhost:5432/postgres?keepalives=1 &keepalives_idle=1 "

This commit changes the parsing so as spaces before and after parameters
and values are discarded, offering more consistency with the parsing
that already applied to libpq for integer values in URIs.

Note that %20 can be used in a URI for a space character.  ECPGconnect()
has been discarded leading and trailing spaces around parameters and
values that for a long time, as well.  Like f22e84df1dea, this is done
as a HEAD-only change.

Reviewed-by: Yuto Sasaki
Discussion: https://postgr.es/m/Zv3oWOfcrHTph7JK@paquier.xyz
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/t/001_uri.pl