Skip to content

Commit

Permalink
fix linkspam and invite regex, because discord hyperlinks the weirdes…
Browse files Browse the repository at this point in the history
…t shit (#1840)

Co-authored-by: Ashish <ashishjh-bst@users.noreply.github.com>
  • Loading branch information
ashishjh-bst and ashishjh-bst authored Feb 11, 2025
1 parent 734ff53 commit 088a77f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common/invites.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type InviteSource struct {

var DiscordInviteSource = &InviteSource{
Name: "Discord",
Regex: regexp.MustCompile(`(?i)(discord\.gg|discordapp\.com\/+invite|discord\.com\/+invite)(?:\/+#)?\/+([a-zA-Z0-9-]+)`),
Regex: regexp.MustCompile(`(?i)(discord\.gg|discordapp\.com\/+invite|discord\.com\/+invite)(?:\/+#)?[\/\\]+([a-zA-Z0-9-]+)`),
}

var ThirdpartyDiscordSites = []*InviteSource{
Expand Down
2 changes: 1 addition & 1 deletion common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
func KeyGuild(guildID int64) string { return "guild:" + discordgo.StrID(guildID) }
func KeyGuildChannels(guildID int64) string { return "channels:" + discordgo.StrID(guildID) }

var LinkRegex = regexp.MustCompile(`(?i)([a-z\d]+://)([\w-._~:/?#\[\]@!$&'()*+,;%=]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])`)
var LinkRegex = regexp.MustCompile(`(?i)([a-z\d]+:[//])([\w-._~:/?#\[\]@!$&'()*+,;%=]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])`)
var DomainFinderRegex = regexp.MustCompile(`(?i)(?:[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?\.)+[a-z\d][a-z\d-]{0,61}[a-z\d]`)
var UGCHtmlPolicy = bluemonday.NewPolicy().AllowElements("h1", "h2", "h3", "h4", "h5", "h6", "p", "ol", "ul", "li", "dl", "dd", "dt", "blockquote", "table", "thead", "th", "tr", "td", "tbody", "del", "i", "b")
var ForwardSlashReplacer = strings.NewReplacer("\\", "")
Expand Down

0 comments on commit 088a77f

Please sign in to comment.