agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Álvaro Herrera <alvherre@kurilemu.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix calculating length of match to localized month/weekday names
Date: Wed, 05 Aug 2026 13:58:52 +0000
Message-ID: <E1wrc8y-00000000JFs-31uM@gemulon.postgresql.org> (raw)
Fix calculating length of match to localized month/weekday names
seq_search_localized() returns the length of the matching prefix in
*len, but because it internally case-folds the inputs, it gets
confused on the length. The caller expects to get the length of the
prefix in the original string, but what it actually returns is the
length of the prefix after case-folding, which can be different if the
case-folded characters have different byte-length than the original,
or with ICU, if the case-folding changes the number of characters
(e.g. "ß", the German double s).
To fix, once we have determined that we have a match, work harder to
find the match's length in the original string. This adds some
overhead, but the strings are expected to be short.
The function does "case-folding" by converting a string to upper-case,
then to lower-case, which is a little ugly given that we have
dedicated functions for case-folding nowadays. But switching to that
doesn't seem appropriate to backpatch in a security fix, and that's
not available in older stable versions, anyway.
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Reported-by: Xint Code
Reviewed-by: Jeff Davis <pgsql@j-davis.com>
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/fd2b89854d93d70fe8c9a69d5b8fafd5b9302cfc
Modified Files
--------------
src/backend/utils/adt/formatting.c | 146 ++++++++++++++++++++---
src/test/regress/expected/collate.linux.utf8.out | 18 +++
src/test/regress/sql/collate.linux.utf8.sql | 3 +
3 files changed, 150 insertions(+), 17 deletions(-)
view thread (7+ messages) latest in thread
Message-ID: <E1wrc8y-00000000JFs-31uM@gemulon.postgresql.org>
Permalink: ../E1wrc8y-00000000JFs-31uM@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wrc8y-00000000JFs-31uM@gemulon.postgresql.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: alvherre@kurilemu.de, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix calculating length of match to localized month/weekday names
In-Reply-To: <E1wrc8y-00000000JFs-31uM@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox