feat(chat): Implement robust link filtering and sanitization #108
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/link-removal-chatroom"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds a comprehensive, multi-layered sanitization function to the chat system to detect and block users from posting links. This enhances user security, reduces spam, and lessens the burden on moderators.
The filtering logic is applied to all incoming and outgoing messages and includes several layers of defense:
Standard URL Detection: Blocks common URL formats, including those with http://, https://, and www. prefixes.
Obfuscation Defenses: Normalizes messages before scanning to defeat common bypass techniques. This includes removing all spaces and replacing text like (dot) and (slash) with their real character equivalents.
Homoglyph Protection: Implements a manual replacement for the most common Cyrillic characters that are visually identical to Latin characters (e.g., 'о', 'а', 'е'). This prevents advanced bypass attempts using confusable characters.
Reduced False Positives: The detection regex is carefully crafted to be specific to valid domain name characters, preventing it from incorrectly flagging filenames (e.g., setup.exe) or other legitimate text as links.