From 0dc16ba76b45db61f04ff7db2bd586f09d6b1b1b Mon Sep 17 00:00:00 2001 From: DarthSim Date: Thu, 15 Sep 2022 22:36:47 +0600 Subject: [PATCH] Fix path before signature check --- CHANGELOG.md | 2 +- processing_handler.go | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12d5648a..743e9397 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - (pro) Add encrypted source URL support. ### Changed -- Fix some invalid signature cases that happen because of URL normalization. +- Try to fix some invalid source URL cases that happen because of URL normalization. ## [3.7.2] - 2022-08-22 ### Changed diff --git a/processing_handler.go b/processing_handler.go index a3cdf8c4..d55b8092 100644 --- a/processing_handler.go +++ b/processing_handler.go @@ -217,14 +217,10 @@ func handleProcessing(reqID string, rw http.ResponseWriter, r *http.Request) { )) } - if err := security.VerifySignature(signature, path); err != nil { - // Some proxy servers may normalize URL and make signature invalid. - // Try to fix the path and repeat the check - path = fixPath(path) + path = fixPath(path) - if err = security.VerifySignature(signature, path); err != nil { - sendErrAndPanic(ctx, "security", ierrors.New(403, err.Error(), "Forbidden")) - } + if err := security.VerifySignature(signature, path); err != nil { + sendErrAndPanic(ctx, "security", ierrors.New(403, err.Error(), "Forbidden")) } po, imageURL, err := options.ParsePath(path, r.Header)