This is an automated email from the ASF dual-hosted git repository.
AlinsRan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new d07f5364e fix(brotli): don't log expected non-standard ETag at error
level (#13545)
d07f5364e is described below
commit d07f5364e246e4e65591dc7fb950e8ddcfc9684e
Author: AlinsRan <[email protected]>
AuthorDate: Mon Jun 15 10:44:27 2026 +0800
fix(brotli): don't log expected non-standard ETag at error level (#13545)
---
apisix/plugins/brotli.lua | 11 +++++++----
t/plugin/brotli.t | 23 +++++++++++++++++++++--
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/apisix/plugins/brotli.lua b/apisix/plugins/brotli.lua
index f8522e98a..e458ac57d 100644
--- a/apisix/plugins/brotli.lua
+++ b/apisix/plugins/brotli.lua
@@ -158,12 +158,15 @@ local function weak_etag_header()
return
end
- local regex = [[^(W/)?"(.*)"$]]
+ local regex = [[^(W/)?"([^"]*)"$]]
local matched, err = ngx.re.match(etag, regex, "jo")
- if not matched or err then
- -- not standard etag, no quote
+ if err then
+ core.log.error("failed to match etag: ", err)
+ end
+ if not matched then
+ -- non-standard etag (not quoted) or a match failure; it cannot be
+ -- weakened, so drop it
core.response.set_header("Etag", nil)
- core.log.error("no standard etag or regex match failed: ", err)
return
end
diff --git a/t/plugin/brotli.t b/t/plugin/brotli.t
index 7e83e1c7b..ae3e31254 100644
--- a/t/plugin/brotli.t
+++ b/t/plugin/brotli.t
@@ -833,8 +833,8 @@ Content-Encoding: br
Vary:
Etag:
Content-Length:
---- error_log
-no standard etag or regex match failed:
+--- no_error_log
+[error]
@@ -888,3 +888,22 @@ Vary:
Etag: W/"123456789"
Last-Modified: Thu, 27 Nov 2025 00:32:33 GMT
Content-Length:
+
+
+
+=== TEST 37: etag with embedded quotes is non-standard, clear it
+--- request
+POST /echo
+0123456789
+012345678
+--- more_headers
+Accept-Encoding: br
+Content-Type: text/html
+Etag: "12"34"
+--- response_headers
+Content-Encoding: br
+Vary:
+Etag:
+Content-Length:
+--- no_error_log
+[error]