Open
Conversation
1. 修复 handle_change 中 `or` 应为 `and` 的逻辑错误(api.py)
- `path != "" or path is not None` 恒为 True,导致未传递的参数
以 None/空值覆盖已有的有效配置
2. 修复 DefaultRefer.__init__ 忽略构造函数参数(api.py)
- 构造函数声明了 path/text/language 参数但未使用,直接引用
全局 args 变量,导致类无法正确复用
3. 修复 GET /tts 端点参数为 None 时 AttributeError(api_v2.py)
- text_lang 和 prompt_lang 默认值为 None,未提供时直接调用
None.lower() 导致崩溃
4. 替换 eval() 为安全的字符串比较(inference_webui.py)
- eval() 会执行任意代码,当环境变量被恶意设置时存在代码
注入风险,改用安全的字符串比较
Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
1. [HIGH] api.py handle_change 中
or应为and(条件恒真)/change_refer端点中:当 path="" 时,path is not None 为 True;当 path=None 时,path != "" 为 True。 导致未传递的参数以 None/空值覆盖已有配置。
2. [MEDIUM] api.py DefaultRefer.init 忽略构造函数参数
构造函数声明了 path, text, language 参数,但函数体直接引用全局 args 变量, 参数完全被忽略。
3. [HIGH] api_v2.py GET /tts 端点缺少 None 检查
text_lang 和 prompt_lang 默认值为 None,未提供时直接调用 None.lower() 导致 AttributeError。
4. [HIGH] inference_webui.py eval() 解析环境变量
eval(os.environ.get("is_share", "False")) 会执行任意 Python 代码。 项目自身的 config.py 已使用安全的字符串比较,此处改为一致的安全方式。
修改内容
测试方案
通过 /change_refer 只更新部分参数,验证未传参数不被覆盖
GET /tts 不传 text_lang 参数,验证不再崩溃
设置环境变量 is_share=True / is_half=False ,验证正确解析