Update the invite Regex pattern with a new accepted format. #6586
No reviewers
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!6586
Loading…
Reference in a new issue
No description provided.
Delete branch "patch-3"
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?
Description of the changes
Hello,

Last week we noticed on several servers where I'm staff that a new invite format is displayed by Discord as valid but is not currently supported by most bots, leaving the door open to scam bots. The new format is
discordapp.com/invite\<code>.I'm using this modified pattern in one of my cogs, while waiting for a modification in Red.
Thanks in advance,
Have a nice day,
AAA3A
Have the changes in this PR been tested?
Yes
This isn't really a "new" format, it is a byproduct of the fact that chrome (and chromium based browsers, like the discord client) assume backslash characters are typo'd forwards slash characters. Maybe this became a "workaround" recently due to invite links embeding even when not a clickable URL... Technically any of the slashes could be backslashes and still be a valid URL for a chromium based browser, though only some cases actually render the invite embed in the discord client.
Any of the following will trigger the embed:
discord.com/invite\reddiscordapp.com/invite\redhttps://discord.gg\red(visually appears with a forward slash since the link is clickable)But these will not trigger the embed:
discord.gg\redon its own withouthttps://discord.com\invite/reddiscordapp.com\invite/redInterestingly, putting backslashes in
https:\\does not cause the link to become clickable or for the invite embed to appear, despite chromium based browsers accepting it as a valid URL.I wouldn't trust any of this behavior to never change again. The safest thing to do is probably to union every slash in both the invite URL and the link URL regexs to match either a forward or a backslash, since either way someone is clearly trying to advertise, even if an embed doesn't appear.
Yes, it's not a "new" format, but it's something that has been detected by Discord as an invite since very recently and that some scams are starting to use.
Would you like me to add the union for each slash, and to the other pattern as well?
It's probably a good time to mention that this regex also catches
promos.discord.gglinks, which are not server invites (https://github.com/Twentysix26/x26-Cogs/issues/57)This could be solved with a negative lookbehind, which should result in
(?<!promos\.)(discord\.(?:gg|io|me|li)|discord(?:app)?\.com\/invite)[\/\\](\S+)Thanks!