mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 07:06:30 +00:00
Escape double-quotes in strings passed to an event notification script
The string in question will be generated internally by repmgr as a simple one-line string with no control characters etc., so all that needs to be escaped at the moment are any double quotes.
This commit is contained in:
25
strutil.c
25
strutil.c
@@ -369,6 +369,31 @@ escape_string(PGconn *conn, const char *string)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* simple function to escape double quotes only
|
||||
*/
|
||||
|
||||
void
|
||||
escape_double_quotes(char *string, PQExpBufferData *out)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
for (ptr = string; *ptr; ptr++)
|
||||
{
|
||||
if (*ptr == '"')
|
||||
{
|
||||
if ( (ptr == string) || (ptr > string && *(ptr - 1) != '\\'))
|
||||
{
|
||||
appendPQExpBufferChar(out, '\\');
|
||||
}
|
||||
}
|
||||
appendPQExpBufferChar(out, *ptr);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
string_skip_prefix(const char *prefix, char *string)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user