From 310d8183138ffc95e20c7fab58f435c8c043fa75 Mon Sep 17 00:00:00 2001 From: XOF Date: Mon, 15 Dec 2025 03:50:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20proxy/rewriter.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/rewriter.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/proxy/rewriter.go b/proxy/rewriter.go index fd93cdc..76755a1 100644 --- a/proxy/rewriter.go +++ b/proxy/rewriter.go @@ -70,6 +70,27 @@ func (r *ContentRewriter) rewriteNode(n *html.Node) { } } + // 处理
标签 - 确保 action 属性存在 + if n.Data == "form" { + hasAction := false + for i, attr := range n.Attr { + if attr.Key == "action" { + hasAction = true + // 空 action 表示提交到当前页面 + if attr.Val == "" { + n.Attr[i].Val = r.rewriteURL(r.baseURL.String()) + } + break + } + } + // 如果没有 action 属性,添加一个 + if !hasAction { + n.Attr = append(n.Attr, html.Attribute{ + Key: "action", + Val: r.rewriteURL(r.baseURL.String()), + }) + } + } // 处理 标签 if n.Data == "base" { for i, attr := range n.Attr {