Skip to content

Commit

Permalink
format: sanitize username for null
Browse files Browse the repository at this point in the history
ref #64
  • Loading branch information
vaxerski committed Feb 23, 2024
1 parent f85287a commit 4c68780
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/renderer/widgets/IWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down

0 comments on commit 4c68780

Please sign in to comment.