diff --git a/index.html b/index.html index 745cc38..1670341 100644 --- a/index.html +++ b/index.html @@ -148,7 +148,7 @@

Systém pro správu a sledování firemních úkolů

- diff --git a/main.go b/main.go index a3bef21..13bb554 100644 --- a/main.go +++ b/main.go @@ -162,7 +162,7 @@ func handleSubmit(w http.ResponseWriter, r *http.Request) { // handleOpenFolder opens a Windows Explorer window to the specified folder path func handleOpenFolder(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") - + // Only allow POST requests if r.Method != http.MethodPost { if r.Method == http.MethodOptions { @@ -173,12 +173,12 @@ func handleOpenFolder(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(map[string]string{"error": "Only POST method is allowed"}) return } - + // Parse the request body type FolderRequest struct { Path string `json:"path"` } - + var req FolderRequest err := json.NewDecoder(r.Body).Decode(&req) if err != nil { @@ -187,25 +187,25 @@ func handleOpenFolder(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(map[string]string{"error": "Failed to parse request body"}) return } - + // Validate the folder path if req.Path == "" { w.WriteHeader(http.StatusBadRequest) json.NewEncoder(w).Encode(map[string]string{"error": "Path is required"}) return } - + // Sanitize the path (basic security - you might want to add more validation) // Ensure it's a valid Windows network path - if !strings.HasPrefix(req.Path, "M:\\") { + if !strings.HasPrefix(req.Path, "C:\\") { w.WriteHeader(http.StatusBadRequest) json.NewEncoder(w).Encode(map[string]string{"error": "Only network paths on M: drive are allowed"}) return } - + // Construct the command to open Windows Explorer cmd := exec.Command("explorer.exe", req.Path) - + // Run the command err = cmd.Start() if err != nil { @@ -214,7 +214,7 @@ func handleOpenFolder(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(map[string]string{"error": fmt.Sprintf("Failed to open folder: %v", err)}) return } - + // Send a success response json.NewEncoder(w).Encode(map[string]string{"status": "success", "message": "Folder opened successfully"}) }