Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a8db85c026
Коммит
053dcf62b6
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/html/charset"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/app/oembed"
|
||||
)
|
||||
@@ -62,6 +63,8 @@ func (a *App) parseOpenGraphMetadata(requestURL string, body io.Reader, contentT
|
||||
|
||||
openGraphDecodeHTMLEntities(og)
|
||||
|
||||
og = filterSVGImagesFromOpenGraph(og)
|
||||
|
||||
// If image proxy enabled modify open graph data to feed though proxy
|
||||
if toProxyURL := a.ImageProxyAdder(); toProxyURL != nil {
|
||||
og = openGraphDataWithProxyAddedToImageURLs(og, toProxyURL)
|
||||
@@ -143,6 +146,16 @@ func openGraphDataWithProxyAddedToImageURLs(ogdata *opengraph.OpenGraph, toProxy
|
||||
return ogdata
|
||||
}
|
||||
|
||||
// filterSVGImagesFromOpenGraph removes SVG images from OpenGraph metadata.
|
||||
func filterSVGImagesFromOpenGraph(og *opengraph.OpenGraph) *opengraph.OpenGraph {
|
||||
if og == nil || len(og.Images) == 0 {
|
||||
return og
|
||||
}
|
||||
|
||||
og.Images = model.FilterSVGImages(og.Images)
|
||||
return og
|
||||
}
|
||||
|
||||
func openGraphDecodeHTMLEntities(og *opengraph.OpenGraph) {
|
||||
og.Title = html.UnescapeString(og.Title)
|
||||
og.Description = html.UnescapeString(og.Description)
|
||||
@@ -169,6 +182,8 @@ func (a *App) parseOpenGraphFromOEmbed(requestURL string, body io.Reader) (*open
|
||||
})
|
||||
}
|
||||
|
||||
og = filterSVGImagesFromOpenGraph(og)
|
||||
|
||||
if toProxyURL := a.ImageProxyAdder(); toProxyURL != nil {
|
||||
og = openGraphDataWithProxyAddedToImageURLs(og, toProxyURL)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user