Merge remote-tracking branch 'origin/fix/webdav-decode-issue' into fix/webdav-decode-issue

pull/9268/head
千石 2025-08-16 19:20:12 +08:00
commit d1a44633c1
1 changed files with 0 additions and 33 deletions

View File

@ -1,33 +0,0 @@
package webdav
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/alist-org/alist/v3/pkg/utils"
)
func TestMakePropstatResponseKeepsEncodedHref(t *testing.T) {
// Non-ASCII directory path
dir := "/测试"
href := utils.EncodePath(dir, true)
ps := []Propstat{{Status: http.StatusOK}}
rec := httptest.NewRecorder()
mw := multistatusWriter{w: rec}
if err := mw.write(makePropstatResponse(href, ps)); err != nil {
t.Fatalf("write: %v", err)
}
if err := mw.close(); err != nil {
t.Fatalf("close: %v", err)
}
if rec.Code != StatusMulti {
t.Fatalf("status = %d, want %d", rec.Code, StatusMulti)
}
body := rec.Body.String()
if !strings.Contains(body, "<D:href>"+href+"</D:href>") {
t.Fatalf("href not preserved: got body %q", body)
}
}