fixed image url validation
Signed-off-by: Ben Hall <ben@benh.codes>
This commit is contained in:
parent
474a9bd408
commit
e7cb111874
@ -172,10 +172,8 @@ var urlRegex = regexp.MustCompile(`^https?://([-a-zA-Z0-9@:%._+~#=]{1,256})\.[a-
|
|||||||
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)) {
|
||||||
if *url != "%avatar_url%" {
|
|
||||||
return validation.NewInvalidInputError("Invalid URL")
|
return validation.NewInvalidInputError("Invalid URL")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -361,6 +359,18 @@ func validateAccessControlList(ctx PanelValidationContext) validation.Validation
|
|||||||
|
|
||||||
func validateEmbed(e *types.CustomEmbed) error {
|
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 != "%avatar_url%" {
|
||||||
|
return validation.NewInvalidInputError("Invalid URL")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if e.ThumbnailUrl != nil && (len(*e.ThumbnailUrl) > 255 || !urlRegex.MatchString(*e.ThumbnailUrl)) {
|
||||||
|
if *e.ThumbnailUrl != "%avatar_url%" {
|
||||||
|
return validation.NewInvalidInputError("Invalid URL")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user