8000 [pull] main from miniflux:main by pull[bot] · Pull Request #229 · suhaoGe/miniflux · GitHub
[go: up one dir, main page]

Skip to content
Merged
8000
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/config/options.go
8000
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package config // import "miniflux.app/v2/internal/config"

import (
"maps"
"net"
"net/url"
"slices"
"strings"
Expand Down Expand Up @@ -564,6 +565,15 @@ func NewConfigOptions() *configOptions {
parsedStringList: []string{},
rawValue: "",
valueType: stringListType,
validator: func(rawValue string) error {
for ip := range strings.SplitSeq(rawValue, ",") {
if _, _, err := net.ParseCIDR(ip); err != nil {
return err
}
}

return nil
},
},
"WATCHDOG": {
parsedBoolValue: true,
Expand Down
5 changes: 5 additions & 0 deletions internal/config/options_parsing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,11 @@ func TestTrustedReverseProxyNetworksOptionParsing(t *testing.T) {
if !slices.Contains(allowedNetworks, "192.168.1.0/24") {
t.Errorf("Expected 192.168.1.0/24 in allowed networks")
}

// Test invalid value
if err := configParser.parseLines([]string{"TRUSTED_REVERSE_PROXY_NETWORKS=127.0.0.1"}); err == nil {
t.Fatal("Expected error when parsing invalid CIDR notation IP 127.0.0.1, got nil")
}
}

func TestYouTubeEmbedDomainOptionParsing(t *testing.T) {
Expand Down
14 changes: 7 additions & 7 deletions internal/reader/subscription/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,13 @@ func (f *subscriptionFinder) FindSubscriptions(websiteURL, rssBridgeURL string,

func (f *subscriptionFinder) findSubscriptionsFromWebPage(websiteURL, contentType string, body []byte) (Subscriptions, *locale.LocalizedErrorWrapper) {
queries := map[string]string{
"link[type='application/rss+xml']": parser.FormatRSS,
"link[type='application/atom+xml']": parser.FormatAtom,
"link[type='application/json'], link[type='application/feed+json']": parser.FormatJSON,
"link[type='application/rss+xml']": parser.FormatRSS,
"link[type='application/atom+xml']": parser.FormatAtom,
"link[type='application/feed+json']": parser.FormatJSON,

// Ignore JSON feed URLs that contain "/wp-json/" to avoid confusion
// with WordPress REST API endpoints.
"link[type='application/json']:not([href*='/wp-json/'])": parser.FormatJSON,
}

htmlDocumentReader, err := encoding.NewCharsetReaderFromBytes(body, contentType)
Expand Down Expand Up @@ -148,10 +152,6 @@ func (f *subscriptionFinder) findSubscriptionsFromWebPage(websiteURL, contentTyp
subscription.Type = feedFormat

if feedURL, exists := s.Attr("href"); exists && feedURL != "" {
// Ignore JSON feed URLs that contain "wp-json" to avoid confusion with WordPress REST API endpoints.
if feedFormat == parser.FormatJSON && strings.Contains(feedURL, "wp-json") {
return
}
subscription.URL, err = urllib.ResolveToAbsoluteURL(websiteURL, feedURL)
if err != nil {
return
Expand Down
Loading
0