Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions code/sys/sys_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,41 @@ void Sys_AnsiColorPrint( const char *msg )
}
}

/*
=================
Sys_ReplaceNonPrintableChars
=================
*/
void Sys_ReplaceNonPrintableChars(char *str)
{
char *p;

for (p = str; *p != '\0'; p++)
{
if ( !isprint(*p) && *p != '\n' )
{
*p = '.';
}
}
}

/*
=================
Sys_Print
=================
*/
void Sys_Print( const char *msg )
{
CON_LogWrite( msg );
CON_Print( msg );
char clean_msg[ MAXPRINTMSG ];

// Replace non-printable characters before we print the string
// Prevents abuse, e.g. players messing up the terminal by \say-ing
// escape sequences
Q_strncpyz(clean_msg, msg, sizeof(clean_msg));
Sys_ReplaceNonPrintableChars(clean_msg);

CON_LogWrite( clean_msg );
CON_Print( clean_msg );
}

/*
Expand Down
Loading