From 25bf4ab55a2533875acd1dc8b5eb11229bd3ba45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Thu, 10 Aug 2023 09:50:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=8C=BA/=E7=9C=81=E4=BB=BD=E5=B0=81?= =?UTF-8?q?=E7=A6=81=E6=8F=90=E7=A4=BA=E4=B8=AD=E6=94=AF=E6=8C=81=E5=8F=98?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_request_waf.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/nodes/http_request_waf.go b/internal/nodes/http_request_waf.go index 5d8feba..c5eba0d 100644 --- a/internal/nodes/http_request_waf.go +++ b/internal/nodes/http_request_waf.go @@ -175,10 +175,11 @@ func (this *HTTPRequest) checkWAFRequest(firewallPolicy *firewallconfigs.HTTPFir this.firewallPolicyId = firewallPolicy.Id if len(regionConfig.CountryHTML) > 0 { + var formattedHTML = this.Format(regionConfig.CountryHTML) this.writer.Header().Set("Content-Type", "text/html; charset=utf-8") - this.writer.Header().Set("Content-Length", types.String(len(regionConfig.CountryHTML))) + this.writer.Header().Set("Content-Length", types.String(len(formattedHTML))) this.writer.WriteHeader(http.StatusForbidden) - _, _ = this.writer.Write([]byte(regionConfig.CountryHTML)) + _, _ = this.writer.Write([]byte(formattedHTML)) } else { this.writeCode(http.StatusForbidden, "The region has been denied.", "当前区域禁止访问") } @@ -203,10 +204,11 @@ func (this *HTTPRequest) checkWAFRequest(firewallPolicy *firewallconfigs.HTTPFir this.firewallPolicyId = firewallPolicy.Id if len(regionConfig.ProvinceHTML) > 0 { + var formattedHTML = this.Format(regionConfig.ProvinceHTML) this.writer.Header().Set("Content-Type", "text/html; charset=utf-8") - this.writer.Header().Set("Content-Length", types.String(len(regionConfig.ProvinceHTML))) + this.writer.Header().Set("Content-Length", types.String(len(formattedHTML))) this.writer.WriteHeader(http.StatusForbidden) - _, _ = this.writer.Write([]byte(regionConfig.ProvinceHTML)) + _, _ = this.writer.Write([]byte(formattedHTML)) } else { this.writeCode(http.StatusForbidden, "The region has been denied.", "当前区域禁止访问") }