Merge a9de96f30f0ab6ca8a131e72cbfc1ad6c190b62a into 97492174a61f6b92ad30c1c7cfb3c4eded660ae9
This commit is contained in:
commit
86b67cd4dd
@ -167,12 +167,12 @@ func validateEmoji(c PanelValidationContext) validation.ValidationFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var urlRegex = regexp.MustCompile(`^https?://([-a-zA-Z0-9@:%._+~#=]{1,256})\.[a-zA-Z0-9()]{1,63}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$`)
|
var urlRegex = regexp.MustCompile(`^https?://([-a-zA-Z0-9@:%._+~#=]{1,256})\.[a-zA-Z0-9()]{1,63}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*\.(?:gif|jpg|jpeg|png|webp))$`)
|
||||||
|
|
||||||
func validateNullableUrl(url *string) validation.ValidationFunc {
|
func validateNullableUrl(url *string) validation.ValidationFunc {
|
||||||
return func() error {
|
return func() error {
|
||||||
if url != nil && (len(*url) > 255 || !urlRegex.MatchString(*url)) {
|
if url != nil && (len(*url) > 255 || !urlRegex.MatchString(*url)) {
|
||||||
return validation.NewInvalidInputError("Invalid URL")
|
return validation.NewInvalidInputError("Invalid image URL. Must end with .gif, .jpg, .jpeg, .png, or .webp")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -361,13 +361,13 @@ func validateEmbed(e *types.CustomEmbed) error {
|
|||||||
if e == nil || e.Title != nil || e.Description != nil || len(e.Fields) > 0 || e.ImageUrl != nil || e.ThumbnailUrl != nil {
|
if e == nil || e.Title != nil || e.Description != nil || len(e.Fields) > 0 || e.ImageUrl != nil || e.ThumbnailUrl != nil {
|
||||||
if e.ImageUrl != nil && (len(*e.ImageUrl) > 255 || !urlRegex.MatchString(*e.ImageUrl)) {
|
if e.ImageUrl != nil && (len(*e.ImageUrl) > 255 || !urlRegex.MatchString(*e.ImageUrl)) {
|
||||||
if *e.ImageUrl != "%avatar_url%" {
|
if *e.ImageUrl != "%avatar_url%" {
|
||||||
return validation.NewInvalidInputError("Invalid URL")
|
return validation.NewInvalidInputError("Invalid image URL. Must end with .gif, .jpg, .jpeg, .png, or .webp")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.ThumbnailUrl != nil && (len(*e.ThumbnailUrl) > 255 || !urlRegex.MatchString(*e.ThumbnailUrl)) {
|
if e.ThumbnailUrl != nil && (len(*e.ThumbnailUrl) > 255 || !urlRegex.MatchString(*e.ThumbnailUrl)) {
|
||||||
if *e.ThumbnailUrl != "%avatar_url%" {
|
if *e.ThumbnailUrl != "%avatar_url%" {
|
||||||
return validation.NewInvalidInputError("Invalid URL")
|
return validation.NewInvalidInputError("Invalid image URL. Must end with .gif, .jpg, .jpeg, .png, or .webp")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user