🐛 File system exception when exporting docs containing ../ hyperlinks to Markdown Fix https://github.com/siyuan-note/siyuan/issues/9779

This commit is contained in:
Daniel 2023-11-30 12:37:33 +08:00
parent ee351057f1
commit c9f90c606e
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 22 additions and 6 deletions

View file

@ -190,6 +190,10 @@ func IsSubPath(absPath, toCheckPath string) bool {
if 1 > len(absPath) || 1 > len(toCheckPath) {
return false
}
if absPath == toCheckPath { // 相同路径时不认为是子路径
return false
}
if gulu.OS.IsWindows() {
if filepath.IsAbs(absPath) && filepath.IsAbs(toCheckPath) {
if strings.ToLower(absPath)[0] != strings.ToLower(toCheckPath)[0] {

View file

@ -268,9 +268,12 @@ func IsDisplayableAsset(p string) bool {
func GetAbsPathInWorkspace(relPath string) (string, error) {
absPath := filepath.Join(WorkspaceDir, relPath)
if WorkspaceDir == absPath {
return absPath, nil
}
if IsSubPath(WorkspaceDir, absPath) {
return absPath, nil
} else {
return "", os.ErrPermission
}
return "", os.ErrPermission
}