fix: validate ISO path is a file, not a directory; clear default value

This commit was merged in pull request #17.
This commit is contained in:
2026-06-22 05:14:18 -07:00
parent ebce8fded8
commit 7e9419e119
2 changed files with 14 additions and 1 deletions
+13
View File
@@ -309,6 +309,19 @@ func handleDiskPartitions(w http.ResponseWriter, r *http.Request) {
writeJSON(w, map[string]any{"error": "missing iso parameter"})
return
}
fi, err := os.Stat(iso)
if err != nil {
writeJSON(w, map[string]any{"error": fmt.Sprintf("cannot access %q: %v", iso, err)})
return
}
if fi.IsDir() {
writeJSON(w, map[string]any{"error": fmt.Sprintf("%q is a directory, not an ISO file", iso)})
return
}
if !strings.HasSuffix(strings.ToLower(fi.Name()), ".iso") {
writeJSON(w, map[string]any{"error": fmt.Sprintf("%q is not an ISO file", iso)})
return
}
parts, err := listPartitions(iso)
if err != nil {
writeJSON(w, map[string]any{"error": err.Error()})