功能 (语音合成):新增语音合成请求的模型名校验
新增模型名最大长度常量,限定字符上限为 64 位 传入模型名称时,校验名称长度并拦截非法控制字符 移除闲置的 tts-api.exe 可执行文件
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user