From c431982168a749c670ed8f8eb9277e1ab97bbc0f Mon Sep 17 00:00:00 2001 From: chengma Date: Mon, 24 Aug 2026 00:15:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=9D=E7=95=99=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E9=A1=B5=E9=9D=A2=E8=BF=94=E5=9B=9E=E7=8A=B6?= =?UTF-8?q?=E6=80=81=20(#294)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/color_mapping_template_test.go | 25 +++++++++++++++++++++++++ admin/handler/web/shopee.go | 2 +- admin/templates/shopee/list.html | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/admin/color_mapping_template_test.go b/admin/color_mapping_template_test.go index 63665d5..58bf56c 100644 --- a/admin/color_mapping_template_test.go +++ b/admin/color_mapping_template_test.go @@ -45,3 +45,28 @@ func TestColorMappingTemplate_渲染分组候选安全表单和独立脚本(t *t } } } + +func TestShopeeListTemplate_颜色匹配入口只编码一次返回地址(t *testing.T) { + tmpl, err := template.ParseFS(templateFS, "templates/*/*.html") + if err != nil { + t.Fatal(err) + } + var output bytes.Buffer + err = tmpl.ExecuteTemplate(&output, "shopee/list", map[string]any{ + "Title": "蝦皮数据", "Active": "shopee", "CSRFToken": "csrf-test", + "CurrentUser": &model.User{UserID: "U-1", Username: "buyer", Role: model.RolePurchaser}, + "Rows": []service.ShopeeProductView{{GoodsID: "S-1", Title: "商品"}}, + "ReturnTo": "/shopee?q=衣服&page=2", "CurrentPage": 2, "CurrentPageSize": 100, + "Status": "共 1 个商品", "DetailURL": "/shopee/detail?", + }) + if err != nil { + t.Fatal(err) + } + html := strings.ToLower(output.String()) + if !strings.Contains(html, "return_to=%2fshopee%3fq%3d") { + t.Fatalf("颜色匹配入口没有正确编码返回地址") + } + if strings.Contains(html, "return_to=%252fshopee") { + t.Fatal("返回地址被重复编码") + } +} diff --git a/admin/handler/web/shopee.go b/admin/handler/web/shopee.go index 3924a81..301ebd6 100644 --- a/admin/handler/web/shopee.go +++ b/admin/handler/web/shopee.go @@ -146,7 +146,7 @@ func (h *Handler) renderShopeeList(c *gin.Context, keyword, searchFieldRaw, stat "DetailURL": "/shopee/detail?" + detailValuesForShopee(values, result.Page), "AutoOpenDetailID": strings.TrimSpace(c.Query("open_id")), "AssignableClients": assignableClients, - "ReturnToEscaped": url.QueryEscape(c.Request.URL.RequestURI()), + "ReturnTo": c.Request.URL.RequestURI(), })) } diff --git a/admin/templates/shopee/list.html b/admin/templates/shopee/list.html index 68c7d57..83c8945 100644 --- a/admin/templates/shopee/list.html +++ b/admin/templates/shopee/list.html @@ -104,7 +104,7 @@ {{.SourceText}} {{if .PddMissing}}未填写{{else}}{{.PddGoodsID}}{{end}} {{.StatusText}} - 进入匹配 + 进入匹配 {{.UpdatedAt}} {{else}}