Pull request 2289: upd-urlfilter

Updates #6818.

Squashed commit of the following:

commit d03b518457ef14d1c565a46c1dbfce1a47bf301d
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Fri Oct 4 18:58:10 2024 +0300

    all: upd chlog

commit 80ee9146998d622c173a9559b8d6af139b750d23
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Fri Oct 4 18:50:24 2024 +0300

    all: upd urlfilter
This commit is contained in:
Stanislav Chzhen
2024-10-04 19:10:32 +03:00
parent df097341c3
commit 2c64ab5a51
7 changed files with 59 additions and 44 deletions

View File

@@ -4,16 +4,17 @@ import (
"bytes"
"fmt"
"io"
"maps"
"mime/multipart"
"net/http"
"net/textproto"
"os"
"path/filepath"
"slices"
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
"github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/golibs/httphdr"
"github.com/AdguardTeam/golibs/mapsutil"
)
// upload base translation.
@@ -52,9 +53,11 @@ func prepareMultipartMsg(
w := multipart.NewWriter(buf)
var fw io.Writer
err = mapsutil.SortedRangeError(formData, w.WriteField)
if err != nil {
return nil, "", fmt.Errorf("writing field: %w", err)
for _, k := range slices.Sorted(maps.Keys(formData)) {
err = w.WriteField(k, formData[k])
if err != nil {
return nil, "", fmt.Errorf("writing field %q: %w", k, err)
}
}
file, err := os.Open(basePath)