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

fix(filter): remove \r\n in rule parsing

This commit is contained in:
Frédéric Guillot 2025-07-16 20:58:53 -07:00
parent 86e2ce6d0b
commit dc81725788
4 changed files with 10 additions and 26 deletions

View file

@ -5,8 +5,6 @@ package ui // import "miniflux.app/v2/internal/ui"
import (
"net/http"
"regexp"
"strings"
"miniflux.app/v2/internal/http/request"
"miniflux.app/v2/internal/http/response/html"
@ -61,14 +59,6 @@ func (h *handler) updateSettings(w http.ResponseWriter, r *http.Request) {
view.Set("countWebAuthnCerts", h.store.CountWebAuthnCredentialsByUserID(loggedUser.ID))
view.Set("webAuthnCerts", creds)
// Sanitize the end of the block & Keep rules
cleanEnd := regexp.MustCompile(`(?m)\r\n\s*$`)
settingsForm.BlockFilterEntryRules = cleanEnd.ReplaceAllLiteralString(settingsForm.BlockFilterEntryRules, "")
settingsForm.KeepFilterEntryRules = cleanEnd.ReplaceAllLiteralString(settingsForm.KeepFilterEntryRules, "")
// Clean carriage returns for Windows environments
settingsForm.BlockFilterEntryRules = strings.ReplaceAll(settingsForm.BlockFilterEntryRules, "\r\n", "\n")
settingsForm.KeepFilterEntryRules = strings.ReplaceAll(settingsForm.KeepFilterEntryRules, "\r\n", "\n")
if validationErr := settingsForm.Validate(); validationErr != nil {
view.Set("errorMessage", validationErr.Translate(loggedUser.Language))
html.OK(w, r, view.Render("settings"))