fix(drivers/189pc)!: normalize escaped apostrophes in names (#2792)

fix(189pc): normalize escaped apostrophes in names

Co-authored-by: Codex <267193182+codex@users.noreply.github.com>
Co-authored-by: Pikachu Ren <40362270+PIKACHUIM@users.noreply.github.com>
This commit is contained in:
qbisicwate
2026-08-29 01:32:57 +08:00
committed by GitHub
parent d12bd4c71e
commit d220b8b005
2 changed files with 19 additions and 3 deletions
+8
View File
@@ -191,6 +191,10 @@ type Cloud189File struct {
// StarLabel int64 `json:"starLabel"`
}
func normalizeCloud189Name(name string) string {
return strings.ReplaceAll(name, "\\'", "'")
}
func (c *Cloud189File) CreateTime() time.Time {
return time.Time(c.CreateDate)
}
@@ -207,6 +211,8 @@ func (c *Cloud189File) GetID() string { return string(c.ID) }
func (c *Cloud189File) GetPath() string { return "" }
func (c *Cloud189File) Thumb() string { return c.Icon.SmallUrl }
func (c *Cloud189File) GetDisplayName() string { return normalizeCloud189Name(c.Name) }
// 文件夹
type Cloud189Folder struct {
ID String `json:"id"`
@@ -238,6 +244,8 @@ func (c *Cloud189Folder) IsDir() bool { return true }
func (c *Cloud189Folder) GetID() string { return string(c.ID) }
func (c *Cloud189Folder) GetPath() string { return "" }
func (c *Cloud189Folder) GetDisplayName() string { return normalizeCloud189Name(c.Name) }
type Cloud189FilesResp struct {
//ResCode int `json:"res_code"`
//ResMessage string `json:"res_message"`
+11 -3
View File
@@ -19,6 +19,10 @@ type ObjUnwrap interface {
Unwrap() Obj
}
type ObjDisplayName interface {
GetDisplayName() string
}
type Obj interface {
GetSize() int64
GetName() string
@@ -132,13 +136,17 @@ func ExtractFolder(objs []Obj, extractFolder string) {
})
}
func WrapObjName(objs Obj) Obj {
return &ObjWrapName{Name: utils.MappingName(objs.GetName()), Obj: objs}
func WrapObjName(obj Obj) Obj {
name := obj.GetName()
if displayName, ok := obj.(ObjDisplayName); ok {
name = displayName.GetDisplayName()
}
return &ObjWrapName{Name: utils.MappingName(name), Obj: obj}
}
func WrapObjsName(objs []Obj) {
for i := range objs {
objs[i] = &ObjWrapName{Name: utils.MappingName(objs[i].GetName()), Obj: objs[i]}
objs[i] = WrapObjName(objs[i])
}
}