mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 23:26: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:
10
dbutils.c
10
dbutils.c
@@ -27,7 +27,6 @@
|
||||
#include "repmgr.h"
|
||||
#include "dbutils.h"
|
||||
#include "controldata.h"
|
||||
|
||||
#include "dirutil.h"
|
||||
|
||||
/* mainly for use by repmgrd */
|
||||
@@ -3086,6 +3085,7 @@ _create_event(PGconn *conn, t_configuration_options *options, int node_id, char
|
||||
char *end_ptr = NULL;
|
||||
int r = 0;
|
||||
|
||||
log_verbose(LOG_DEBUG, "_create_event(): command is '%s'", options->event_notification_command);
|
||||
/*
|
||||
* If configuration option 'event_notifications' was provided, check
|
||||
* if this event is one of the ones listed; if not listed, don't
|
||||
@@ -3164,8 +3164,14 @@ _create_event(PGconn *conn, t_configuration_options *options, int node_id, char
|
||||
src_ptr++;
|
||||
if (details != NULL)
|
||||
{
|
||||
strlcpy(dst_ptr, details, end_ptr - dst_ptr);
|
||||
PQExpBufferData details_escaped;
|
||||
initPQExpBuffer(&details_escaped);
|
||||
|
||||
escape_double_quotes(details, &details_escaped);
|
||||
|
||||
strlcpy(dst_ptr, details_escaped.data, end_ptr - dst_ptr);
|
||||
dst_ptr += strlen(dst_ptr);
|
||||
termPQExpBuffer(&details_escaped);
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
|
||||
Reference in New Issue
Block a user