From 3b87974bd0854b22152f6b4107654e9ede8af70f Mon Sep 17 00:00:00 2001 From: Harald van Dijk Date: Sat, 11 Oct 2025 08:43:10 +0100 Subject: [PATCH] Fix links after emoji MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JavaScript strings are encoded as UTF-16. When a Unicode character outside of the BMP is part of a string, it is encoded as a surrogate pair. For instance, '🎨' is encoded as '\uD83C\uDFA8', but a for-of loop will treat that as a single character with length 2. In getByteToCharMap, this was not handled, resulting in an incorrect value of charIndex and links being placed at the wrong location in messages. --- src/components/UniversalPostRenderer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/UniversalPostRenderer.tsx b/src/components/UniversalPostRenderer.tsx index 3a67f07..533a590 100644 --- a/src/components/UniversalPostRenderer.tsx +++ b/src/components/UniversalPostRenderer.tsx @@ -2297,7 +2297,7 @@ function getByteToCharMap(text: string): number[] { for (let i = 0; i < bytes.length; i++) { map[byteIndex++] = charIndex; } - charIndex++; + charIndex+=char.length; } return map; -- 2.43.0