Skip to content

Commit

Permalink
fixed accidentally creating a segfault due to wrong typing
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Oct 15, 2023
1 parent 1b7a087 commit 4e8b870
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions server/backend/cron/news.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,26 @@ func (c *CronService) parseNewsFeed(source model.NewsSource) error {
}
var enclosureUrl = null.StringFrom("")
var file *model.File
var fileID null.Int
if pickedEnclosure != nil {
file, err = c.saveImage(pickedEnclosure.URL)
if err != nil {
log.WithError(err).Error("can't save news image")
log.WithError(err).WithField("url", pickedEnclosure.URL).Error("can't save news image")
} else {
fileID = null.IntFrom(file.File)
}
enclosureUrl = null.StringFrom(pickedEnclosure.URL)
}
bm := bluemonday.StrictPolicy()
sanitizedDesc := bm.Sanitize(item.Description)

newsItem := model.News{
Date: *item.PublishedParsed,
Created: time.Now(),
Title: item.Title,
Description: sanitizedDesc,
Description: bluemonday.StrictPolicy().Sanitize(item.Description),
Src: source.Source,
Link: item.Link,
Image: enclosureUrl,
FileID: null.IntFrom(file.File),
FileID: fileID,
File: file,
}
newNews = append(newNews, newsItem)
Expand Down

0 comments on commit 4e8b870

Please sign in to comment.