Skip to content

Commit

Permalink
fix: 修复非法字符输入
Browse files Browse the repository at this point in the history
  • Loading branch information
Ackites committed Aug 12, 2024
1 parent f3e8a4a commit 2b1686d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/unpack/uconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ func changeExt(filename, newExt string) string {

// save 保存内容到文件
func save(filename string, content []byte) error {
// 处理文件路径
filename = filepath.ToSlash(filename)
if idx := strings.Index(filename, ":"); idx != -1 {
filename = filename[:idx+1] + strings.ReplaceAll(filename[idx+1:], ":", "")
}

// 判断目录是否存在
dir := filepath.Dir(filename)
if _, err := os.Stat(dir); os.IsNotExist(err) {
Expand Down Expand Up @@ -240,7 +246,7 @@ func (p *ConfigParser) Parse(option config.WxapkgInfo) error {
windowContent, _ := json.MarshalIndent(e.Page[a].Window, "", " ")
err = save(fileName, windowContent)
if err != nil {
return err
log.Printf("Error saving file %s: %v\n", fileName, err)
}
}
}
Expand Down

0 comments on commit 2b1686d

Please sign in to comment.