AlinsRan opened a new pull request, #13545:
URL: https://github.com/apache/apisix/pull/13545

   ### What this fixes
   
   `apisix/plugins/brotli.lua` `weak_etag_header()` downgrades a strong `ETag` 
to a weak one (Brotli alters the body, so a strong validator no longer holds). 
When the upstream `ETag` is **not** a quoted string, the regex simply does not 
match — an expected case — but the code logs it at **error** level:
   
   ```lua
   local matched, err = ngx.re.match(etag, regex, "jo")
   if not matched or err then
       core.response.set_header("Etag", nil)
       core.log.error("no standard etag or regex match failed: ", err)  -- err 
is nil here
       return
   end
   ```
   
   So every response carrying a non-quoted ETag produces `... error ... : nil` 
noise in the error log.
   
   ### Change
   
   - Only log at `error` level when `ngx.re.match` actually returns an error; 
otherwise drop the ETag silently (behavior unchanged).
   - Tighten the capture group from `(.*)` to `([^"]*)` so a malformed ETag 
containing internal quotes is treated as non-standard (and dropped) rather than 
weakened into another malformed value.
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [ ] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change (N/A)
   - [x] I have verified that the changes pass the existing tests
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to