更新 proxy/rewriter.go
This commit is contained in:
@@ -70,6 +70,27 @@ func (r *ContentRewriter) rewriteNode(n *html.Node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理 <form> 标签 - 确保 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()),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
// 处理 <base> 标签
|
// 处理 <base> 标签
|
||||||
if n.Data == "base" {
|
if n.Data == "base" {
|
||||||
for i, attr := range n.Attr {
|
for i, attr := range n.Attr {
|
||||||
|
|||||||
Reference in New Issue
Block a user