From 881f9779e6ba74a0336d44782910c65328930871 Mon Sep 17 00:00:00 2001 From: calixteman Date: Thu, 26 Feb 2026 16:46:34 +0100 Subject: [PATCH] Don't check for surrogates when verifying the chars to normalize --- web/pdf_find_utils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/pdf_find_utils.js b/web/pdf_find_utils.js index bb52a4623..ef8160e2c 100644 --- a/web/pdf_find_utils.js +++ b/web/pdf_find_utils.js @@ -140,6 +140,9 @@ function getNormalizeWithNFKC() { const diacriticsRegex = /^\p{M}$/u; // Some chars must be replaced by their NFKC counterpart during a search. for (let i = 0; i < 65536; i++) { + if (i >= 0xd800 && i <= 0xdfff) { + continue; // Skip surrogates since they're not valid Unicode scalar values. + } const c = String.fromCharCode(i); if (c.normalize("NFKC") !== c && !diacriticsRegex.test(c)) { if (range.length !== 2) {