1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-07-02 16:38:37 +00:00

Remove carriage returns to sanitizer strings from windows

This commit is contained in:
Krish Mamtora 2024-07-03 09:04:54 -04:00 committed by Frédéric Guillot
parent 92db691344
commit a09ddbbaf4
2 changed files with 9 additions and 0 deletions

View file

@ -6,6 +6,7 @@ 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"
@ -58,6 +59,9 @@ func (h *handler) updateSettings(w http.ResponseWriter, r *http.Request) {
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))