Skip to content

Commit ac0cf58

Browse files
Potential fix for code scanning alert no. 134: Log entries created from user input
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent fec0e8f commit ac0cf58

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/ollama/handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ func (h *Handler) handleChat(w http.ResponseWriter, r *http.Request) {
357357
sanitizedModelName := strings.ReplaceAll(strings.ReplaceAll(modelName, "\n", ""), "\r", "")
358358
h.log.Infof("handleChat: model=%s, keep_alive=%v", sanitizedModelName, req.KeepAlive)
359359
if req.KeepAlive == "0" || req.KeepAlive == "0s" || req.KeepAlive == "0m" {
360-
h.log.Infof("handleChat: unloading model %s due to keep_alive=%s", sanitizedModelName, req.KeepAlive)
360+
sanitizedKeepAlive := strings.ReplaceAll(strings.ReplaceAll(req.KeepAlive, "\n", ""), "\r", "")
361+
h.log.Infof("handleChat: unloading model %s due to keep_alive=%s", sanitizedModelName, sanitizedKeepAlive)
361362
h.unloadModel(ctx, w, modelName)
362363
return
363364
}

0 commit comments

Comments
 (0)