mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
fix potential nil deref
This commit is contained in:
parent
f3e1f7b276
commit
095bcd496e
@ -54,6 +54,7 @@ func (a *App) parseOpenGraphMetadata(requestURL string, body io.Reader, contentT
|
||||
|
||||
if err := og.ProcessHTML(body); err != nil {
|
||||
mlog.Warn("parseOpenGraphMetadata processing failed", mlog.String("requestURL", requestURL), mlog.Err(err))
|
||||
return nil, nil, errors.New("parseOpenGraphMetadata processing failed")
|
||||
}
|
||||
|
||||
makeOpenGraphURLsAbsolute(og, requestURL)
|
||||
|
@ -800,7 +800,10 @@ func (a *App) parseLinkMetadata(requestURL string, body io.Reader, contentType s
|
||||
image, err := parseImages(io.LimitReader(body, MaxMetadataImageSize))
|
||||
return nil, image, err
|
||||
} else if strings.HasPrefix(contentType, "text/html") {
|
||||
og, _, _ := a.parseOpenGraphMetadata(requestURL, body, contentType)
|
||||
og, _, err := a.parseOpenGraphMetadata(requestURL, body, contentType)
|
||||
if err != nil {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
// The OpenGraph library and Go HTML library don't error for malformed input, so check that at least
|
||||
// one of these required fields exists before returning the OpenGraph data
|
||||
|
Loading…
Reference in New Issue
Block a user