mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-29 14:37:05 +00:00
File loader: Check file extensions without resolving symlinks (#7255)
https://github.com/XTLS/Xray-core/pull/7255#issuecomment-6481194940 https://github.com/XTLS/Xray-core/pull/7250#issuecomment-6398816842 Fixes https://github.com/XTLS/Xray-core/issues/7239#issuecomment-6356122816 --------- Co-authored-by: Eljees <3.14hell@gmail.com>
This commit is contained in:
committed by
RPRX
co-authored by
Eljees
parent
bca08ac080
commit
35a3121a83
Vendored
+2
-10
@@ -58,18 +58,10 @@ func readConfigFile(file *os.File) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
if info.Mode().IsRegular() {
|
||||
path, err := filepath.Abs(file.Name())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
path, err = filepath.EvalSymlinks(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch strings.ToLower(filepath.Ext(path)) {
|
||||
switch strings.ToLower(filepath.Ext(file.Name())) {
|
||||
case ".jsonc", ".json", ".yml", ".yaml", ".toml", ".pb", ".protobuf":
|
||||
default:
|
||||
return nil, errors.New("unsupported config file extension: ", path)
|
||||
return nil, errors.New("unsupported config file extension: ", file.Name())
|
||||
}
|
||||
}
|
||||
return io.ReadAll(file)
|
||||
|
||||
Reference in New Issue
Block a user