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

   ### What this fixes
   
   The elasticsearch-logger dynamic-index feature (`index` may contain 
`{time_format}` placeholders) passes the user-controlled format straight to 
`os.date`:
   
   ```lua
   -- apisix/plugins/elasticsearch-logger.lua, replace_time()
   local time = os_date(time_format)
   if not time then ... end
   ```
   
   `os.date` **raises** (rather than returning `nil`) on some invalid 
`strftime` escapes, so a crafted `index` value throws in the log phase instead 
of degrading gracefully — the existing `if not time` guard never gets a chance 
to run.
   
   ### Change
   
   Wrap the `os.date` call in `pcall` and fall back to an empty replacement on 
failure, matching the intent of the existing nil-check.
   
   ### 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