-
-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better discord webhook url regex #208
Conversation
Better webhook url regex, to allow other subdomains such as ptb & canary which are actively used as well as allowing for the detection of webhooks using the old domain discordapp.com and allowing for the matching of webhook urls that include the api version after the api path and more distinct expressions for webhook tokens and webhook ids, also allowing for webhook urls that have the scheme of http
pywhat/Data/regex.json
Outdated
@@ -832,7 +832,7 @@ | |||
}, | |||
{ | |||
"Name": "Discord Webhook", | |||
"Regex": "(?i)^(https://discord\\.com/api/webhooks/[0-9]+/[A-Za-z0-9-_]+)$", | |||
"Regex": "(?i)^(https?:\/\/(?:ptb\.|canary\.)?discord(?:app)?\.com\/api(?:\/v\d{1,2})?\/webhooks\/(\d{17,19})\/([\w\-]{68}))$", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance we can get tests for ptb, canary and discordapp ? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing! :)
Added more discord webhook test candidates, to test the api version string and the new subdomains & domains (ptb, canary and discordapp)
Hopefully this escaped everything
Forgot to escape one more character class
More escaping of regex in the JSON file
Hopefully this is the final commit
Fix indent
"https://canary.discord.com/api/v9/webhooks/894893734582452235/KhNc2-_zwY9FfCAK0iGUa_KfYyW8m5Ja_5i-V24fEY6ETwvLLn-GmdT_vq0Do9-YRsij", | ||
"https://discordapp.com/api/v9/webhooks/894893734582452235/KhNc2-_zwY9FfCAK0iGUa_KfYyW8m5Ja_5i-V24fEY6ETwvLLn-GmdT_vq0Do9-YRsij", | ||
"https://ptb.discordapp.com/api/v9/webhooks/894893734582452235/KhNc2-_zwY9FfCAK0iGUa_KfYyW8m5Ja_5i-V24fEY6ETwvLLn-GmdT_vq0Do9-YRsij", | ||
"https://canary.discordapp.com/api/v9/webhooks/894893734582452235/KhNc2-_zwY9FfCAK0iGUa_KfYyW8m5Ja_5i-V24fEY6ETwvLLn-GmdT_vq0Do9-YRsij" | ||
] | ||
) | ||
_assert_match_first_item("Discord Webhook", res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only testing that one of these URLs works, not that all of them work. Please make them into separate functions? :) <3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On it!
Codecov Report
@@ Coverage Diff @@
## main #208 +/- ##
=======================================
Coverage 94.46% 94.46%
=======================================
Files 14 14
Lines 1717 1717
=======================================
Hits 1622 1622
Misses 95 95
Continue to review full report at Codecov.
|
Added loads of test candidates and updated discord webhook regex as per bee-san#208
Prerequisites
Why do we need this pull request?
Better webhook url regex, to allow other subdomains such as ptb & canary which are actively used as well as allowing for the detection of webhooks using the old domain discordapp.com and allowing for the matching of webhook urls that include the api version after the api path and more distinct expressions for webhook tokens and webhook ids, also allowing for webhook urls that have the scheme of http
What GitHub issues does this fix?
Expands upon changes made in #173
Copy / paste of output
Couldn't get the script to work so I could not test the changes to the regex i've made with the regex however I have tested it on its own in python 3.10 as well as using https://pythex.org