avoid panic crash due to bad environment variable values; closes pterodactyl/panel#2275
This commit is contained in:
parent
0dde54fc8f
commit
60acee2df5
|
@ -2,6 +2,7 @@ package environment
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/apex/log"
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
@ -118,7 +119,13 @@ func (v Variables) Get(key string) string {
|
||||||
return fmt.Sprintf("%f", val.(float64))
|
return fmt.Sprintf("%f", val.(float64))
|
||||||
case bool:
|
case bool:
|
||||||
return strconv.FormatBool(val.(bool))
|
return strconv.FormatBool(val.(bool))
|
||||||
|
case string:
|
||||||
|
return val.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
return val.(string)
|
// TODO: I think we can add a check for val == nil and return an empty string for those
|
||||||
|
// and this warning should theoretically never happen?
|
||||||
|
log.Warn(fmt.Sprintf("failed to marshal environment variable \"%s\" of type %+v into string", key, val))
|
||||||
|
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user