mirror of
https://github.com/HugeFrog24/go-telegram-bot.git
synced 2026-03-02 00:14:34 +00:00
docs
rm unused params fix test test workflow security add ci badge
This commit is contained in:
12
config.go
12
config.go
@@ -143,9 +143,11 @@ func validateConfig(config *BotConfig, ids, tokens map[string]bool) error {
|
||||
|
||||
func loadConfig(filename string) (BotConfig, error) {
|
||||
var config BotConfig
|
||||
file, err := os.OpenFile(filename, os.O_RDONLY, 0)
|
||||
// Use filepath.Clean before opening the file
|
||||
cleanPath := filepath.Clean(filename)
|
||||
file, err := os.OpenFile(cleanPath, os.O_RDONLY, 0)
|
||||
if err != nil {
|
||||
return config, fmt.Errorf("failed to open config file %s: %w", filename, err)
|
||||
return config, fmt.Errorf("failed to open config file %s: %w", cleanPath, err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
@@ -165,9 +167,11 @@ func (c *BotConfig) Reload(configDir, filename string) error {
|
||||
return fmt.Errorf("invalid config path: %w", err)
|
||||
}
|
||||
|
||||
file, err := os.OpenFile(validPath, os.O_RDONLY, 0)
|
||||
// Use filepath.Clean before opening the file
|
||||
cleanPath := filepath.Clean(validPath)
|
||||
file, err := os.OpenFile(cleanPath, os.O_RDONLY, 0)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open config file %s: %w", validPath, err)
|
||||
return fmt.Errorf("failed to open config file %s: %w", cleanPath, err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user