format: sanitize username for null

ref #64
This commit is contained in:
Vaxry 2024-02-23 13:04:08 +00:00
parent f85287a523
commit 4c68780143
1 changed files with 6 additions and 1 deletions

View File

@ -48,8 +48,13 @@ static std::string getTime() {
IWidget::SFormatResult IWidget::formatString(std::string in) {
char* username = getlogin();
if (!username)
Debug::log(ERR, "Error in formatString, username null. Errno: ", errno);
IWidget::SFormatResult result;
replaceAll(in, "$USER", std::string{getlogin()});
replaceAll(in, "$USER", std::string{username ? username : ""});
replaceAll(in, "<br/>", std::string{"\n"});
if (in.contains("$TIME")) {