From 508eb7ab5feb5c236a0a67931ca7c3274f256f03 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 16 Nov 2021 15:50:04 +0300 Subject: [PATCH] engine: restore command escaping --- engine/common/cmd.c | 36 +++++++++++++++++++++++++++++++++++- engine/common/common.h | 1 + 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/engine/common/cmd.c b/engine/common/cmd.c index 56f63d57..165ac933 100644 --- a/engine/common/cmd.c +++ b/engine/common/cmd.c @@ -983,7 +983,7 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr cmd_condlevel = 0; // cvar value substitution - if( cmd_scripting && cmd_scripting->value ) + if( CVAR_TO_BOOL( cmd_scripting )) { while( *text ) { @@ -1330,9 +1330,43 @@ void Cmd_Null_f( void ) { } +/* +========== +Cmd_Escape + +inserts escape sequences +========== +*/ +void Cmd_Escape( char *newCommand, const char *oldCommand, int len ) +{ + int c; + int scripting = CVAR_TO_BOOL( cmd_scripting ); + + while( (c = *oldCommand++) && len > 1 ) + { + if( c == '"' ) + { + *newCommand++ = '\\'; + len--; + } + + if( scripting && c == '$') + { + *newCommand++ = '$'; + len--; + } + + *newCommand++ = c; len--; + } + + *newCommand++ = 0; +} + + /* ============ Cmd_Init + ============ */ void Cmd_Init( void ) diff --git a/engine/common/common.h b/engine/common/common.h index 59d0a346..0c54664f 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -503,6 +503,7 @@ qboolean Cmd_GetMovieList( const char *s, char *completedname, int length ); void Cmd_TokenizeString( const char *text ); void Cmd_ExecuteString( const char *text ); void Cmd_ForwardToServer( void ); +void Cmd_Escape( char *newCommand, const char *oldCommand, int len ); // // zone.c