Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a8db85c026
Коммит
053dcf62b6
@@ -339,6 +339,18 @@ func (a *App) getEmbedForPost(c request.CTX, post *model.Post, firstLink string,
|
||||
}
|
||||
|
||||
if image != nil {
|
||||
// See MM-67372
|
||||
if image.Format == "svg" || model.IsSVGImageURL(firstLink) {
|
||||
c.Logger().Debug("Skipping SVG image embed",
|
||||
mlog.String("post_id", post.Id),
|
||||
mlog.String("url", firstLink))
|
||||
// Return a link embed instead of an image embed
|
||||
return &model.PostEmbed{
|
||||
Type: model.PostEmbedLink,
|
||||
URL: firstLink,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Note that we're not passing the image info here since it'll be part of the PostMetadata.Images field
|
||||
return &model.PostEmbed{
|
||||
Type: model.PostEmbedImage,
|
||||
@@ -617,6 +629,24 @@ func (a *App) containsPermalink(rctx request.CTX, post *model.Post) bool {
|
||||
return looksLikeAPermalink(link, a.GetSiteURL())
|
||||
}
|
||||
|
||||
// filterSVGImage filters out SVG images (MM-67372).
|
||||
// Returns nil if the image is an SVG, otherwise returns the image unchanged.
|
||||
func filterSVGImage(image *model.PostImage, imageURL string) *model.PostImage {
|
||||
if image == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if image.Format == "svg" {
|
||||
return nil
|
||||
}
|
||||
|
||||
if model.IsSVGImageURL(imageURL) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return image
|
||||
}
|
||||
|
||||
func (a *App) getLinkMetadata(c request.CTX, requestURL string, timestamp int64, isNewPost bool, previewedPostPropVal string) (*opengraph.OpenGraph, *model.PostImage, *model.Permalink, error) {
|
||||
requestURL = resolveMetadataURL(requestURL, a.GetSiteURL())
|
||||
|
||||
@@ -634,6 +664,8 @@ func (a *App) getLinkMetadata(c request.CTX, requestURL string, timestamp int64,
|
||||
}
|
||||
|
||||
if ok && previewedPostPropVal == "" {
|
||||
og = model.TruncateOpenGraph(og)
|
||||
image = filterSVGImage(image, requestURL)
|
||||
return og, image, permalink, nil
|
||||
}
|
||||
|
||||
@@ -641,6 +673,8 @@ func (a *App) getLinkMetadata(c request.CTX, requestURL string, timestamp int64,
|
||||
if !isNewPost {
|
||||
og, image, ok = a.getLinkMetadataFromDatabase(requestURL, timestamp)
|
||||
if ok && previewedPostPropVal == "" {
|
||||
og = model.TruncateOpenGraph(og)
|
||||
image = filterSVGImage(image, requestURL)
|
||||
cacheLinkMetadata(c, requestURL, timestamp, og, image, nil)
|
||||
return og, image, nil, nil
|
||||
}
|
||||
@@ -890,12 +924,11 @@ func (a *App) parseLinkMetadata(rctx request.CTX, requestURL string, body io.Rea
|
||||
body = bufRd
|
||||
}
|
||||
|
||||
if contentType == "image/svg+xml" {
|
||||
image := &model.PostImage{
|
||||
Format: "svg",
|
||||
}
|
||||
|
||||
return nil, image, nil
|
||||
if strings.HasPrefix(contentType, "image/svg+xml") {
|
||||
// See MM-67372
|
||||
rctx.Logger().Debug("Filtering SVG image from link metadata",
|
||||
mlog.String("url", requestURL))
|
||||
return nil, nil, nil
|
||||
} else if strings.HasPrefix(contentType, "image") {
|
||||
image, err := parseImages(rctx, requestURL, io.LimitReader(body, MaxMetadataImageSize))
|
||||
return nil, image, err
|
||||
|
||||
Ссылка в новой задаче
Block a user