Co-authored-by: clawbot <clawbot@openclaw> Co-authored-by: Jeffrey Paul <sneak@noreply.example.org> Reviewed-on: #18 Co-authored-by: clawbot <clawbot@noreply.example.org> Co-committed-by: clawbot <clawbot@noreply.example.org>
This commit was merged in pull request #18.
This commit is contained in:
@@ -113,7 +113,7 @@ func (mfa *CLIApp) fetchManifestOperation(ctx *cli.Context) error {
|
||||
return fmt.Errorf("invalid path in manifest: %w", err)
|
||||
}
|
||||
|
||||
fileURL := baseURL.String() + f.Path
|
||||
fileURL := baseURL.String() + encodeFilePath(f.Path)
|
||||
log.Infof("fetching %s", f.Path)
|
||||
|
||||
if err := downloadFile(fileURL, localPath, f, progress); err != nil {
|
||||
@@ -139,6 +139,15 @@ func (mfa *CLIApp) fetchManifestOperation(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// encodeFilePath URL-encodes each segment of a file path while preserving slashes.
|
||||
func encodeFilePath(p string) string {
|
||||
segments := strings.Split(p, "/")
|
||||
for i, seg := range segments {
|
||||
segments[i] = url.PathEscape(seg)
|
||||
}
|
||||
return strings.Join(segments, "/")
|
||||
}
|
||||
|
||||
// sanitizePath validates and sanitizes a file path from the manifest.
|
||||
// It prevents path traversal attacks and rejects unsafe paths.
|
||||
func sanitizePath(p string) (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user