Skip to content

Commit

Permalink
sign with path instead of filename
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Nov 11, 2022
1 parent feecb83 commit 79401dd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions alist-proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"io"
"net/http"
"path"
"strings"

"github.com/alist-org/alist/v3/pkg/sign"
Expand Down Expand Up @@ -64,8 +63,7 @@ func errorResponse(w http.ResponseWriter, code int, msg string) {
func downHandle(w http.ResponseWriter, r *http.Request) {
sign := r.URL.Query().Get("sign")
filePath := r.URL.Path
fileName := path.Base(filePath)
err := s.Verify(fileName, sign)
err := s.Verify(filePath, sign)
if err != nil {
errorResponse(w, 401, err.Error())
return
Expand Down Expand Up @@ -124,7 +122,7 @@ func downHandle(w http.ResponseWriter, r *http.Request) {
_ = res2.Body.Close()
}()
for h, v := range res2.Header {
if strings.ToLower(h) == strings.ToLower("Access-Control-Allow-Origin") {
if strings.EqualFold(h, "Access-Control-Allow-Origin") {
continue
}
w.Header()[h] = v
Expand Down

0 comments on commit 79401dd

Please sign in to comment.