mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-05 00:34:01 +08:00
URL跳转时检查前后跳转的URL是否一致,防止无限跳转
This commit is contained in:
@@ -27,6 +27,12 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) {
|
|||||||
if u.KeepRequestURI {
|
if u.KeepRequestURI {
|
||||||
afterURL += this.RawReq.URL.RequestURI()
|
afterURL += this.RawReq.URL.RequestURI()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 前后是否一致
|
||||||
|
if fullURL == afterURL {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if u.Status <= 0 {
|
if u.Status <= 0 {
|
||||||
http.Redirect(this.RawWriter, this.RawReq, afterURL, http.StatusTemporaryRedirect)
|
http.Redirect(this.RawWriter, this.RawReq, afterURL, http.StatusTemporaryRedirect)
|
||||||
} else {
|
} else {
|
||||||
@@ -60,6 +66,11 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 前后是否一致
|
||||||
|
if fullURL == afterURL {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if u.Status <= 0 {
|
if u.Status <= 0 {
|
||||||
http.Redirect(this.RawWriter, this.RawReq, afterURL, http.StatusTemporaryRedirect)
|
http.Redirect(this.RawWriter, this.RawReq, afterURL, http.StatusTemporaryRedirect)
|
||||||
} else {
|
} else {
|
||||||
@@ -68,6 +79,11 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) {
|
|||||||
return true
|
return true
|
||||||
} else { // 精准匹配
|
} else { // 精准匹配
|
||||||
if fullURL == u.RealBeforeURL() {
|
if fullURL == u.RealBeforeURL() {
|
||||||
|
// 前后是否一致
|
||||||
|
if fullURL == u.AfterURL {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if u.Status <= 0 {
|
if u.Status <= 0 {
|
||||||
http.Redirect(this.RawWriter, this.RawReq, u.AfterURL, http.StatusTemporaryRedirect)
|
http.Redirect(this.RawWriter, this.RawReq, u.AfterURL, http.StatusTemporaryRedirect)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user