重构:Wails升级/mermaid主题切换/代码高亮修复/文件系统UI重构
- Wails v2.12.0升级(App绑定新增API、runtime类型扩展) - 修复mermaid暗色主题切换渲染失败(SVG textContent污染→data-mermaid-src保存源码) - 修复代码高亮全语言失效(languageMap静态白名单替代运行时hljs检查) - 文件系统:FileListPanel重写、FileItemRow合并删除、Toolbar简化 - 新增剪贴板图片粘贴(Ctrl+V粘贴图片到当前目录) - 死代码清理:DeviceTest/errorHandler/useLocalStorage移除 - MarkdownEditor优化、theme store增强、CodeMirror加载器精简
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// PathValidator 路径验证器接口
|
||||
@@ -180,16 +181,25 @@ func (v *DefaultPathValidator) isSensitivePath(path string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// 默认路径验证器(缓存,避免每次调用重复初始化)
|
||||
var (
|
||||
defaultValidatorOnce sync.Once
|
||||
defaultValidator PathValidator
|
||||
)
|
||||
|
||||
func getDefaultValidator() PathValidator {
|
||||
defaultValidatorOnce.Do(func() {
|
||||
defaultValidator = NewPathValidator(DefaultConfig())
|
||||
})
|
||||
return defaultValidator
|
||||
}
|
||||
|
||||
// isSafePath 兼容函数:保持向后兼容
|
||||
// 使用默认配置的路径验证器
|
||||
func isSafePath(path string) bool {
|
||||
validator := NewPathValidator(DefaultConfig())
|
||||
return validator.IsSafe(path)
|
||||
return getDefaultValidator().IsSafe(path)
|
||||
}
|
||||
|
||||
// isSensitivePath 兼容函数:保持向后兼容
|
||||
// 使用默认配置检查敏感路径
|
||||
func isSensitivePath(path string) bool {
|
||||
validator := NewPathValidator(DefaultConfig())
|
||||
return validator.IsSensitive(path)
|
||||
return getDefaultValidator().IsSensitive(path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user