mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-12 10:55:51 +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"
|
||||
"strings"
|
||||
|
@ -32,8 +33,28 @@ func Rename(c *gin.Context) {
|
|||
})
|
||||
return
|
||||
}
|
||||
origFullPath := nginx.GetConfPath(json.BasePath, json.OrigName)
|
||||
newFullPath := nginx.GetConfPath(json.BasePath, json.NewName)
|
||||
|
||||
// Decode paths from URL encoding
|
||||
decodedBasePath, err := url.QueryUnescape(json.BasePath)
|
||||
if err != nil {
|
||||
cosy.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
decodedOrigName, err := url.QueryUnescape(json.OrigName)
|
||||
if err != nil {
|
||||
cosy.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
decodedNewName, err := url.QueryUnescape(json.NewName)
|
||||
if err != nil {
|
||||
cosy.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
origFullPath := nginx.GetConfPath(decodedBasePath, decodedOrigName)
|
||||
newFullPath := nginx.GetConfPath(decodedBasePath, decodedNewName)
|
||||
if !helper.IsUnderDirectory(origFullPath, nginx.GetConfPath()) ||
|
||||
!helper.IsUnderDirectory(newFullPath, nginx.GetConfPath()) {
|
||||
c.JSON(http.StatusForbidden, gin.H{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue