mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
🐛 File system exception when exporting docs containing ../ hyperlinks to Markdown Fix https://github.com/siyuan-note/siyuan/issues/9779
This commit is contained in:
parent
ee351057f1
commit
c9f90c606e
3 changed files with 22 additions and 6 deletions
|
|
@ -432,7 +432,7 @@ func SearchAssetsByName(keyword string, exts []string) (ret []*cache.Asset) {
|
|||
return
|
||||
}
|
||||
|
||||
func GetAssetAbsPath(relativePath string) (absPath string, err error) {
|
||||
func GetAssetAbsPath(relativePath string) (ret string, err error) {
|
||||
relativePath = strings.TrimSpace(relativePath)
|
||||
if strings.Contains(relativePath, "?") {
|
||||
relativePath = relativePath[:strings.Index(relativePath, "?")]
|
||||
|
|
@ -455,13 +455,18 @@ func GetAssetAbsPath(relativePath string) (absPath string, err error) {
|
|||
}
|
||||
if p := filepath.ToSlash(path); strings.HasSuffix(p, relativePath) {
|
||||
if gulu.File.IsExist(path) {
|
||||
absPath = path
|
||||
ret = path
|
||||
return io.EOF
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if "" != absPath {
|
||||
|
||||
if "" != ret {
|
||||
if !util.IsSubPath(util.WorkspaceDir, ret) {
|
||||
err = fmt.Errorf("[%s] is not sub path of workspace", ret)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
@ -469,7 +474,11 @@ func GetAssetAbsPath(relativePath string) (absPath string, err error) {
|
|||
// 在全局 assets 路径下搜索
|
||||
p := filepath.Join(util.DataDir, relativePath)
|
||||
if gulu.File.IsExist(p) {
|
||||
absPath = p
|
||||
ret = p
|
||||
if !util.IsSubPath(util.WorkspaceDir, ret) {
|
||||
err = fmt.Errorf("[%s] is not sub path of workspace", ret)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
return "", errors.New(fmt.Sprintf(Conf.Language(12), relativePath))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue