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

Skip to content
Merged
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
8 changes: 4 additions & 4 deletions internal/googlereader/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ func (h *greaderHandler) editTagHandler(w http.ResponseWriter, r *http.Request)
}

n := 0
readEntryIDs := make([]int64, 0)
unreadEntryIDs := make([]int64, 0)
starredEntryIDs := make([]int64, 0)
unstarredEntryIDs := make([]int64, 0)
var readEntryIDs []int64
var unreadEntryIDs []int64
var starredEntryIDs []int64
var unstarredEntryIDs []int64
for _, entry := range entries {
if read, exists := tags[ReadStream]; exists {
if read && entry.Status == model.EntryStatusUnread {
Expand Down
7 changes: 6 additions & 1 deletion internal/http/server/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"

"miniflux.app/v2/internal/config"
"miniflux.app/v2/internal/crypto"
"miniflux.app/v2/internal/http/request"

"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -54,7 +55,11 @@ func isAllowedToAccessMetricsEndpoint(r *http.Request) bool {
return false
}

if username != config.Opts.MetricsUsername() || password != config.Opts.MetricsPassword() {
// Both checks have to be run to avoid leaking informations
// about the username and the password.
usernameCorrect := crypto.ConstantTimeCmp(username, config.Opts.MetricsUsername())
passwordCorrect := crypto.ConstantTimeCmp(password, config.Opts.MetricsPassword())
if !usernameCorrect || !passwordCorrect {
slog.Warn("Metrics endpoint accessed with invalid username or password",
slog.Bool("authentication_failed", true),
slog.String("client_ip", clientIP),
Expand Down
6 changes: 4 additions & 2 deletions internal/reader/date/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ var replacer = strings.NewReplacer(
"Thurs,", "Thu,",
"Thur,", "Thu,",
)
var losAngelesLocation, _ = time.LoadLocation("America/Los_Angeles")
var newYorkLocation, _ = time.LoadLocation("America/New_York")

// Parse parses a given date string using a large
// list of commonly found feed date formats.
Expand Down Expand Up @@ -352,9 +354,9 @@ func parseLocalTimeDates(layout, ds string) (t time.Time, err error) {

// Workaround for dates that don't use GMT.
if strings.HasSuffix(ds, "PST") || strings.HasSuffix(ds, "PDT") {
loc, _ = time.LoadLocation("America/Los_Angeles")
loc = losAngelesLocation
} else if strings.HasSuffix(ds, "EST") || strings.HasSuffix(ds, "EDT") {
loc, _ = time.LoadLocation("America/New_York")
loc = newYorkLocation
}

return time.ParseInLocation(layout, ds, loc)
Expand Down
4 changes: 1 addition & 3 deletions internal/reader/sanitizer/sanitizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,7 @@ func sanitizeAttributes(parsedBaseUrl *url.URL, tagName string, attributes []htm
switch tagName {
case "math":
if attribute.Key == "xmlns" {
if value != "http://www.w3.org/1998/Math/MathML" {
value = "http://www.w3.org/1998/Math/MathML"
}
value = "http://www.w3.org/1998/Math/MathML"
}
case "img":
switch attribute.Key {
Expand Down
28 changes: 15 additions & 13 deletions internal/reader/subscription/finder.go
F438
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,18 @@ func (f *subscriptionFinder) findSubscriptionsFromWebPage(websiteURL string, doc
}

func (f *subscriptionFinder) findSubscriptionsFromWellKnownURLs(websiteURL string) (Subscriptions, *locale.LocalizedErrorWrapper) {
knownURLs := map[string]string{
"atom.xml": parser.FormatAtom,
"feed.atom": parser.FormatAtom,
"feed.xml": parser.FormatAtom,
"feed/": parser.FormatAtom,
"index.rss": parser.FormatRSS,
"index.xml": parser.FormatRSS,
"rss.xml": parser.FormatRSS,
"rss/": parser.FormatRSS,
"rss/feed.xml": parser.FormatRSS,
knownURLs := [...]struct {
path, format string
}{
{"atom.xml", parser.FormatAtom},
{"feed.atom", parser.FormatAtom},
{"feed.xml", parser.FormatAtom},
{"feed/", parser.FormatAtom},
{"index.rss", parser.FormatRSS},
{"index.xml", parser.FormatRSS},
{"rss.xml", parser.FormatRSS},
{"rss/", parser.FormatRSS},
{"rss/feed.xml", parser.FormatRSS},
}

websiteURLRoot := urllib.RootURL(websiteURL)
Expand All @@ -197,8 +199,8 @@ func (f *subscriptionFinder) findSubscriptionsFromWellKnownURLs(websiteURL strin

var subscriptions Subscriptions
for _, baseURL := range baseURLs {
for knownURL, kind := range knownURLs {
fullURL, err := urllib.ResolveToAbsoluteURL(baseURL, knownURL)
for _, known := range knownURLs {
fullURL, err := urllib.ResolveToAbsoluteURL(baseURL, known.path)
if err != nil {
continue
}
Expand Down Expand Up @@ -227,7 +229,7 @@ func (f *subscriptionFinder) findSubscriptionsFromWellKnownURLs(websiteURL strin
}

subscriptions = append(subscriptions, &subscription{
Type: kind,
Type: known.format,
Title: fullURL,
URL: fullURL,
})
Expand Down
4 changes: 2 additions & 2 deletions internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,6 @@ func Serve(store *storage.Storage, pool *worker.Pool) http.Handler {
w.Write([]byte("User-agent: *\nDisallow: /"))
})

// Apply middleware chain: cross-origin protection -> web session -> CSRF validation -> handlers.
return http.NewCrossOriginProtection().Handler(webSessionMiddleware.handle(csrfMiddleware.handle(mux)))
// Apply middleware chain: web session -> CSRF validation -> handlers.
return webSessionMiddleware.handle(csrfMiddleware.handle(mux))
}
5 changes: 0 additions & 5 deletions internal/urllib/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@ func JoinBaseURLAndPath(baseURL, path string) (string, error) {
return "", errors.New("empty path")
}

_, err := url.Parse(baseURL)
if err != nil {
return "", fmt.Errorf("invalid base URL: %w", err)
}

finalURL, err := url.JoinPath(baseURL, path)
if err != nil {
return "", fmt.Errorf("unable to join base URL %s and path %s: %w", baseURL, path, err)
Expand Down
Loading
0