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 {