From 7923719a018fc028428cab88a39266cc237e723a Mon Sep 17 00:00:00 2001 From: EP Date: Sun, 9 Mar 2025 18:48:59 -0400 Subject: [PATCH] Fix emoji encoding with zero-width space and improved detection --- js/steganography.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/js/steganography.js b/js/steganography.js index 9cbe8ea..a0384e8 100644 --- a/js/steganography.js +++ b/js/steganography.js @@ -19,18 +19,30 @@ function encodeEmoji(emoji, text) { const vs15 = '\ufe0e'; // text variation selector (0) const vs16 = '\ufe0f'; // emoji variation selector (1) + // Start with the emoji character let result = emoji; + + // Add variation selectors based on binary representation for (const bit of binary) { result += bit === '0' ? vs15 : vs16; } + // Ensure there's a zero-width space after the encoded content + // This helps with browser rendering + result += '\u200B'; + return result; } function decodeEmoji(text) { if (!text) return ''; - // Extract variation selectors + // Find the first emoji character (looking for common emoji Unicode ranges) + const emojiMatch = text.match(/^([\u{1F300}-\u{1F6FF}\u{2600}-\u{26FF}])/u); + if (!emojiMatch) return ''; + + // Extract variation selectors - remove any zero-width spaces first + text = text.replace(/\u200B/g, ''); const matches = [...text.matchAll(/[\ufe0e\ufe0f]/g)]; if (!matches.length) return '';