mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
enhance: clean filepath
This commit is contained in:
parent
46a9ccbdf1
commit
abd76ff930
2 changed files with 8 additions and 2 deletions
|
@ -18,7 +18,6 @@ func GetConfigs(c *gin.Context) {
|
|||
dir := c.DefaultQuery("dir", "/")
|
||||
|
||||
configFiles, err := os.ReadDir(nginx.GetConfPath(dir))
|
||||
|
||||
if err != nil {
|
||||
api.ErrHandler(c, err)
|
||||
return
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package nginx
|
||||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
"os/exec"
|
||||
|
@ -31,7 +32,13 @@ func GetConfPath(dir ...string) (confPath string) {
|
|||
confPath = settings.NginxSettings.ConfigDir
|
||||
}
|
||||
|
||||
return filepath.Join(confPath, filepath.Join(dir...))
|
||||
joined := filepath.Clean(filepath.Join(confPath, filepath.Join(dir...)))
|
||||
|
||||
if !helper.IsUnderDirectory(confPath, joined) {
|
||||
return confPath
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func GetPIDPath() (path string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue