Re: encode/decode support for base64url
Daniel Gustafsson <daniel@yesql.se>
From: Daniel Gustafsson <daniel@yesql.se>
To: Florents Tselai <florents.tselai@gmail.com>
Cc: "Chao (Evan) Li" <li.evan.chao@gmail.com>, Masahiko Sawada <sawada.mshk@gmail.com>, "David E. Wheeler" <david@justatheory.com>, Aleksander Alekseev <aleksander@tigerdata.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Cary Huang <cary.huang@highgo.ca>, Przemysław Sztoch <przemyslaw@sztoch.pl>
Date: 2025-09-19T07:16:35Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Add support for base64url encoding and decoding
- e1d917182c19 19 (unreleased) landed
Attachments
- v10-0001-Add-support-for-base64url-encoding-and-decoding.patch (application/octet-stream) patch v10-0001
> On 19 Sep 2025, at 08:45, Florents Tselai <florents.tselai@gmail.com> wrote:
>> On 19 Sep 2025, at 6:50 AM, Chao Li <li.evan.chao@gmail.com> wrote:
>> It’s not common to use two white-spaces after “.”, usually we need only one.
>
> I agree with this
This might date me (and others) but double-space after period was the norm for
monospaced typesetting back in the clackety-clack typewriter days, and that
carried over into monospace font text in computers. The fmt program still use
double-space after period (which is what formatted my reply here, thus the use
of double-space in my emails). While there is no hard rule in postgres
(AFAIK), a quick regex shows that it's 2.5x more common for sentences in
comments to have two space after punctuation.
>> The comment is understandable, but slightly vague: remainder of what?
>>
>> Maybe rephrase to “handle remaining bytes in buf”.
>
> Agree too.
I don't think the comment was all that vague in the context of reading the
code, but expanding won't hurt so done.
>> ereport(ERROR,
>> (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
>> - errmsg("unexpected \"=\" while decoding base64 sequence")));
>> + errmsg("unexpected \"=\" while decoding %s sequence", url ? "base64url" : "base64")));
>> ```
>>
>> This is a normal usage that injects sub-strings based on condition. However, PG doesn’t like that, see here: https://www.postgresql.org/docs/devel/nls-programmer.html#NLS-GUIDELINES
>
> Well, that’s a very interesting catch.
> I’ll let a comitter confirm & advise.
Yes and no, the recommendation against constructing sentences at runtime is to
aid translators since the injected string isn't available to them. In this
(and I hope all other) case the injected string should not be translated as it
is a name of an encoding scheme. What we can do is to add a /* translator: ..
*/ comment which will end up in the translation file and give the translator
context on what %s will be replaced by. Done in the attached.
--
Daniel Gustafsson