From 9e06ef66b9bcca1c2cefc5cd38c34a20cb912c41 Mon Sep 17 00:00:00 2001 From: bingoohuang Date: Tue, 9 Feb 2021 09:44:28 +0800 Subject: [PATCH 1/2] fix renaming for 5bytes --- weed/storage/types/offset_5bytes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weed/storage/types/offset_5bytes.go b/weed/storage/types/offset_5bytes.go index 05c6d2f39..b6181fc11 100644 --- a/weed/storage/types/offset_5bytes.go +++ b/weed/storage/types/offset_5bytes.go @@ -71,7 +71,7 @@ func ToOffset(offset int64) Offset { } } -func (offset Offset) ToAcutalOffset() (actualOffset int64) { +func (offset Offset) ToActualOffset() (actualOffset int64) { return (int64(offset.b0) + int64(offset.b1)<<8 + int64(offset.b2)<<16 + int64(offset.b3)<<24 + int64(offset.b4)<<32) * int64(NeedlePaddingSize) } From eab6e31d34bb22beeb1ca416596c44b1590075c0 Mon Sep 17 00:00:00 2001 From: bingoohuang Date: Thu, 18 Feb 2021 14:05:28 +0800 Subject: [PATCH 2/2] use backticks instead of double quotes to avoid escaped additionally in regex --- weed/operation/upload_content.go | 2 +- weed/s3api/s3api_server.go | 2 +- weed/server/volume_server_handlers_read.go | 2 +- weed/storage/disk_location_ec.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go index fccc24b16..abb13bbf7 100644 --- a/weed/operation/upload_content.go +++ b/weed/operation/upload_content.go @@ -62,7 +62,7 @@ func init() { }} } -var fileNameEscaper = strings.NewReplacer("\\", "\\\\", "\"", "\\\"") +var fileNameEscaper = strings.NewReplacer(`\`, `\\`, `"`, `\"`) // Upload sends a POST request to a volume server to upload the content with adjustable compression level func UploadData(uploadUrl string, filename string, cipher bool, data []byte, isInputCompressed bool, mtype string, pairMap map[string]string, jwt security.EncodedJwt) (uploadResult *UploadResult, err error) { diff --git a/weed/s3api/s3api_server.go b/weed/s3api/s3api_server.go index 4993104ae..54df29492 100644 --- a/weed/s3api/s3api_server.go +++ b/weed/s3api/s3api_server.go @@ -64,7 +64,7 @@ func (s3a *S3ApiServer) registerRouter(router *mux.Router) { bucket.Methods("HEAD").HandlerFunc(track(s3a.iam.Auth(s3a.HeadBucketHandler, ACTION_ADMIN), "GET")) // CopyObjectPart - bucket.Methods("PUT").Path("/{object:.+}").HeadersRegexp("X-Amz-Copy-Source", ".*?(\\/|%2F).*?").HandlerFunc(track(s3a.iam.Auth(s3a.CopyObjectPartHandler, ACTION_WRITE), "PUT")).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}") + bucket.Methods("PUT").Path("/{object:.+}").HeadersRegexp("X-Amz-Copy-Source", `.*?(\/|%2F).*?`).HandlerFunc(track(s3a.iam.Auth(s3a.CopyObjectPartHandler, ACTION_WRITE), "PUT")).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}") // PutObjectPart bucket.Methods("PUT").Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.PutObjectPartHandler, ACTION_WRITE), "PUT")).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}") // CompleteMultipartUpload diff --git a/weed/server/volume_server_handlers_read.go b/weed/server/volume_server_handlers_read.go index 1cd4ee21d..0178ffd7d 100644 --- a/weed/server/volume_server_handlers_read.go +++ b/weed/server/volume_server_handlers_read.go @@ -23,7 +23,7 @@ import ( "github.com/chrislusf/seaweedfs/weed/util" ) -var fileNameEscaper = strings.NewReplacer("\\", "\\\\", "\"", "\\\"") +var fileNameEscaper = strings.NewReplacer(`\`, `\\`, `"`, `\"`) func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request) { diff --git a/weed/storage/disk_location_ec.go b/weed/storage/disk_location_ec.go index d1237b40f..ff368c6fc 100644 --- a/weed/storage/disk_location_ec.go +++ b/weed/storage/disk_location_ec.go @@ -14,7 +14,7 @@ import ( ) var ( - re = regexp.MustCompile("\\.ec[0-9][0-9]") + re = regexp.MustCompile(`\.ec[0-9][0-9]`) ) func (l *DiskLocation) FindEcVolume(vid needle.VolumeId) (*erasure_coding.EcVolume, bool) {