1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-16 17:07:43 +03:00

Add support for base64url encoding and decoding

This adds support for base64url encoding and decoding, a base64
variant which is safe to use in filenames and URLs.  base64url
replaces '+' in the base64 alphabet with '-' and '/' with '_',
thus making it safe for URL addresses and file systems.

Support for base64url was originally suggested by Przemysław Sztoch.

Author: Florents Tselai <florents.tselai@gmail.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: David E. Wheeler <david@justatheory.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Chao Li (Evan) <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/70f2b6a8-486a-4fdb-a951-84cef35e22ab@sztoch.pl
This commit is contained in:
Daniel Gustafsson
2025-09-20 23:19:32 +02:00
parent 261f89a976
commit e1d917182c
4 changed files with 359 additions and 21 deletions

View File

@@ -728,6 +728,7 @@
Encodes binary data into a textual representation; supported
<parameter>format</parameter> values are:
<link linkend="encode-format-base64"><literal>base64</literal></link>,
<link linkend="encode-format-base64url"><literal>base64url</literal></link>,
<link linkend="encode-format-escape"><literal>escape</literal></link>,
<link linkend="encode-format-hex"><literal>hex</literal></link>.
</para>
@@ -785,6 +786,24 @@
</listitem>
</varlistentry>
<varlistentry id="encode-format-base64url">
<term>base64url
<indexterm>
<primary>base64url format</primary>
</indexterm></term>
<listitem>
<para>
The <literal>base64url</literal> format is that of
<ulink url="https://datatracker.ietf.org/doc/html/rfc4648#section-5">
RFC 4648 Section 5</ulink>, a <literal>base64</literal> variant safe to
use in filenames and URLs. The <literal>base64url</literal> alphabet
use <literal>'-'</literal> instead of <literal>'+'</literal> and
<literal>'_'</literal> instead of <literal>'/'</literal> and also omits
the <literal>'='</literal> padding character.
</para>
</listitem>
</varlistentry>
<varlistentry id="encode-format-escape">
<term>escape
<indexterm>