mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-12 02:45:49 +02:00
feat(config): use encode/decode to handle url #249
This commit is contained in:
parent
4b8d26cf5b
commit
191ddea309
19 changed files with 235 additions and 82 deletions
|
@ -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"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue