功能 (语音合成):新增语音合成请求的模型名校验

新增模型名最大长度常量,限定字符上限为 64 位
传入模型名称时,校验名称长度并拦截非法控制字符
移除闲置的 tts-api.exe 可执行文件
This commit is contained in:
sun
2026-05-24 11:52:57 +08:00
parent 7bedb222d1
commit 9c35f780db
3 changed files with 12 additions and 0 deletions
+1
View File
@@ -16,4 +16,5 @@ const (
MaxErrors = 10
MaxConcurrentRequests = 10
CleanupInterval = time.Hour
MaxModelNameLength = 64
)
+11
View File
@@ -71,6 +71,17 @@ func OpenaiTTSHandler(w http.ResponseWriter, r *http.Request) {
return
}
if req.Model != "" {
if len(req.Model) > common.MaxModelNameLength {
http.Error(w, fmt.Sprintf("Model name too long (max %d characters)", common.MaxModelNameLength), http.StatusBadRequest)
return
}
if strings.ContainsAny(req.Model, "\x00\n\r\t") {
http.Error(w, "Model name contains invalid characters", http.StatusBadRequest)
return
}
}
if req.Input == "" {
http.Error(w, "Input text is required", http.StatusBadRequest)
return
BIN
View File
Binary file not shown.