1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

fix: URL detection incorrectly capturing newlines in media descriptions

This commit is contained in:
Tim Douglas 2025-08-08 12:34:03 -04:00 committed by Frédéric Guillot
parent 98da7b3f22
commit a4f672b589
2 changed files with 5 additions and 3 deletions

View file

@ -9,7 +9,7 @@ import (
"strings"
)
var textLinkRegex = regexp.MustCompile(`(?mi)(\bhttps?://[^\s]+)[.]?(?:\s|$)`)
var textLinkRegex = regexp.MustCompile(`(?mi)(\bhttps?://[^\s]+)`)
// Specs: https://www.rssboard.org/media-rss
type MediaItemElement struct {
@ -154,8 +154,8 @@ func (d *Description) HTML() string {
return d.Description
}
content := strings.ReplaceAll(d.Description, "\n", "<br>")
return textLinkRegex.ReplaceAllString(content, `<a href="${1}">${1}</a>`)
content := textLinkRegex.ReplaceAllString(d.Description, `<a href="${1}">${1}</a>`)
return strings.ReplaceAll(content, "\n", "<br>")
}
// DescriptionList represents a list of "media:description" XML elements.