(installDir, workspace string)
| 503 | } |
| 504 | |
| 505 | func resolveMarkdownWorkspaceDir(installDir, workspace string) (string, error) { |
| 506 | if workspace == "" { |
| 507 | return "", buserr.New("ErrRecordNotFound") |
| 508 | } |
| 509 | |
| 510 | confDir := path.Join(installDir, "conf") |
| 511 | allowedOpenclawPrefixes := []string{ |
| 512 | "/home/node/.openclaw/workspace/", |
| 513 | "/home/node/.openclaw/workspace-agent_", |
| 514 | } |
| 515 | for _, prefix := range allowedOpenclawPrefixes { |
| 516 | if strings.HasPrefix(workspace, prefix) { |
| 517 | return resolveRoleDir(installDir, workspace), nil |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | cleanWorkspace := path.Clean(workspace) |
| 522 | cleanConfDir := path.Clean(confDir) |
| 523 | if cleanWorkspace == cleanConfDir || strings.HasPrefix(cleanWorkspace, cleanConfDir+"/") { |
| 524 | return cleanWorkspace, nil |
| 525 | } |
| 526 | return "", buserr.New("ErrRecordNotFound") |
| 527 | } |
no test coverage detected