Re: [PATCH] Fix SASLprep validation after NFKC normalization

From: "Robert I Nilsson" <robert(dot)i(dot)nilsson(at)callclue(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Fix SASLprep validation after NFKC normalization
Date: 2026-11-14 10:41:14
Message-ID: 5b965299-d80f-456c-8a6d-8d6a661f4a98@app.fastmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi again,

Attached is v3 of the patch (now with a new title).

This version addresses the five remaining mismatches reported in my previous email. These were caused by Unicode Corrigendum #4, which changed the normalization mappings of five characters in Unicode 4.0. Since SASLprep (RFC 4013) requires Unicode 3.2, the patch now maps these characters to their original Unicode 3.2 values before normalization, as described in Unicode Standard Annex #15, section 11.3.

I've also made a few additional changes:

- Moved the Unicode 3.2 unassigned code point check into the existing mapping loop, avoiding an additional pass over the input.
- Added regression tests for the five affected characters, bringing the total to 18 test cases.
- Made the regression test ordering independent of the database collation.

I reran the comparison against Python's Unicode 3.2 reference implementation using the same test script as before.

The results are now:

- Original PostgreSQL implementation: 104 mismatches
- Initial patch: 704 mismatches
- v2: 5 mismatches
- v3: 0 mismatches

Checked 1,112,210 cases; mismatches: 0

The updated patch includes the five additional regression tests. The standalone Python test script attached to my previous email remains unchanged.

I would appreciate any review or feedback.

Thanks!

Regards,
Robert I Nilsson

Attachment Content-Type Size
v3-0001-Fix-SASLprep-validation-and-Unicode-3.2-compatibi.patch text/x-diff 11.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message JoongHyuk Shin 2026-11-14 10:53:39 Re: [PATCH] Add recovery boundary WAL record for database and tablespace commands
Previous Message Henson Choi 2026-11-14 09:16:44 Re: [DEPARSE] Operators on ROW() constructors read back as row comparisons