feat(config): use encode/decode to handle url #249

This commit is contained in:
Jacky 2025-04-06 10:55:09 +00:00
parent 4b8d26cf5b
commit 191ddea309
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
19 changed files with 235 additions and 82 deletions

View file

@ -2,6 +2,7 @@ package config
import (
"net/http"
"net/url"
"os"
"path/filepath"
"time"
@ -23,6 +24,20 @@ type EditConfigJson struct {
func EditConfig(c *gin.Context) {
relativePath := c.Param("path")
// Ensure the path is correctly decoded - handle cases where it might be encoded multiple times
decodedPath := relativePath
var err error
// Try decoding until the path no longer changes
for {
newDecodedPath, decodeErr := url.PathUnescape(decodedPath)
if decodeErr != nil || newDecodedPath == decodedPath {
break
}
decodedPath = newDecodedPath
}
relativePath = decodedPath
var json struct {
Content string `json:"content"`
SyncOverwrite bool `json:"sync_overwrite"`