Skip to content

Commit

Permalink
Update to sanitize the keep and block rules coming from the settings …
Browse files Browse the repository at this point in the history
…form
  • Loading branch information
privatmamtora committed Jun 29, 2024
1 parent 01ab636 commit 0bf9614
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/ui/settings_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package ui // import "miniflux.app/v2/internal/ui"

import (
"net/http"
"regexp"

"miniflux.app/v2/internal/http/request"
"miniflux.app/v2/internal/http/response/html"
Expand Down Expand Up @@ -53,6 +54,11 @@ 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, "")

if validationErr := settingsForm.Validate(); validationErr != nil {
view.Set("errorMessage", validationErr.Translate(loggedUser.Language))
html.OK(w, r, view.Render("settings"))
Expand Down

0 comments on commit 0bf9614

Please sign in to comment.